Module: Nodaire

Defined in:
lib/nodaire/base.rb,
lib/nodaire/util.rb,
lib/nodaire/lexer.rb,
lib/nodaire/errors.rb

Overview

Nodaire is a collection of text file parsers.

Author:

  • Liam Cooke

Defined Under Namespace

Classes: Indental, ParserError, Tablatal

Constant Summary collapse

VERSION =

The version number.

'0.5.0'
DATE =

The date when this version was released.

'2019-08-26'

Class Method Summary collapse

Class Method Details

.squeeze(string) ⇒ String

Normalize the whitespace in a string.

This strips the string and replaces each sequence of whitespace with a single space.

Parameters:

  • string (String)

Returns:

  • (String)

Since:

  • 0.4.0



17
18
19
# File 'lib/nodaire/util.rb', line 17

def self.squeeze(string)
  (string || '').gsub(/\s+/, ' ').strip
end

.symbolize(string) ⇒ Symbol

Convert a string into a normalized symbol.

This converts to lower case and replaces each sequence of non-alphanumeric characters with an underscore.

Parameters:

  • string (String)

Returns:

  • (Symbol)

Since:

  • 0.4.0



32
33
34
# File 'lib/nodaire/util.rb', line 32

def self.symbolize(string)
  squeeze(string).downcase.gsub(/[^a-z0-9]+/, '_').to_sym
end