Module: Stupidedi::Reader

Defined in:
lib/stupidedi/reader.rb,
lib/stupidedi/reader/input.rb,
lib/stupidedi/reader/result.rb,
lib/stupidedi/reader/position.rb,
lib/stupidedi/reader/separators.rb,
lib/stupidedi/reader/segment_dict.rb,
lib/stupidedi/reader/token_reader.rb,
lib/stupidedi/reader/stream_reader.rb,
lib/stupidedi/reader/input/file_input.rb,
lib/stupidedi/reader/tokens/segment_tok.rb,
lib/stupidedi/reader/input/abstract_input.rb,
lib/stupidedi/reader/input/delegated_input.rb,
lib/stupidedi/reader/tokens/simple_element_tok.rb,
lib/stupidedi/reader/tokens/repeated_element_tok.rb,
lib/stupidedi/reader/tokens/component_element_tok.rb,
lib/stupidedi/reader/tokens/composite_element_tok.rb

Defined Under Namespace

Modules: Input, Result Classes: AbstractInput, ComponentElementTok, CompositeElementTok, DelegatedInput, Failure, FileInput, Position, RepeatedElementTok, SegmentDict, SegmentTok, Separators, SimpleElementTok, StreamReader, Success, TokenReader

Constant Summary collapse

R_BASIC =

Returns:

  • (Regexp)
/[A-Z0-9!"&'()*+,.\/:;?= -]/.freeze
R_EXTENDED =

Returns:

  • (Regexp)
/[a-z%@\[\]_{}\\|<>~^`#\$ÀÁÂÄàáâäÈÉÊèéêëÌÍÎìíîïÒÓÔÖòóôöÙÚÛÜùúûüÇçÑñ¿¡]/.freeze
R_EITHER =

Returns:

  • (Regexp)
Regexp.union(R_BASIC, R_EXTENDED).freeze
C_BYTES =

Returns:

  • (String)
(0..255).inject(""){|string, c| string + [c].pack('U') }
H_BASIC =

Returns:

  • (Hash)
C_BYTES.scan(R_BASIC).inject({}){|h,c| h[c] = nil; h }.freeze
H_EXTENDED =

Returns:

  • (Hash)
C_BYTES.scan(R_EXTENDED).inject({}){|h,c| h[c] = nil; h }.freeze
H_EITHER =

Returns:

  • (Hash)
C_BYTES.scan(R_EITHER).inject({}){|h,c| h[c] = nil; h }.freeze

Constructors collapse

Class Method Summary collapse

Class Method Details

.basic_charactersCharacter

Returns:

  • (Character)


105
106
107
# File 'lib/stupidedi/reader.rb', line 105

def basic_characters
  H_BASIC.keys
end

.build(input) ⇒ StreamReader

Returns:



66
67
68
# File 'lib/stupidedi/reader.rb', line 66

def build(input)
  StreamReader.new(Input.build(input))
end

.control_charactersCharacter

Returns:

  • (Character)


117
118
119
# File 'lib/stupidedi/reader.rb', line 117

def control_characters
  C_BYTES.split(//) - H_EITHER.keys
end

.extended_charactersCharacter

Returns:

  • (Character)


111
112
113
# File 'lib/stupidedi/reader.rb', line 111

def extended_characters
  H_EXTENDED.keys
end

.has_control_characters?(string) ⇒ Boolean

Returns:

  • (Boolean)


99
100
101
# File 'lib/stupidedi/reader.rb', line 99

def has_control_characters?(string)
  #_CONTROL =~ string
end

.has_extended_characters?(string) ⇒ Boolean

Returns:

  • (Boolean)


94
95
96
# File 'lib/stupidedi/reader.rb', line 94

def has_extended_characters?(string)
  R_EXTENDED =~ string
end

.is_basic_character?(character) ⇒ Boolean

Returns:

  • (Boolean)

See Also:

  • B.1.1.2.2 Basic Characters


83
84
85
# File 'lib/stupidedi/reader.rb', line 83

def is_basic_character?(character)
  H_BASIC.include?(character)
end

.is_control_character?(character) ⇒ Boolean

Returns true if ‘character` does not belong to the extended or basic character set.

Returns:

  • (Boolean)

See Also:

  • B.1.1.2.4 Control Characters


77
78
79
# File 'lib/stupidedi/reader.rb', line 77

def is_control_character?(character)
  not H_EITHER.include?(character)
end

.is_extended_character?(character) ⇒ Boolean

Returns:

  • (Boolean)

See Also:

  • B.1.1.2.2 Extended Characters


89
90
91
# File 'lib/stupidedi/reader.rb', line 89

def is_extended_character?(character)
  H_EXTENDED.include?(character)
end