Class: Artificial::Parsers::StringParser
- Inherits:
-
Object
- Object
- Artificial::Parsers::StringParser
- Defined in:
- lib/artificial/parsers/string_parser.rb
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#parsed_data ⇒ Object
readonly
Returns the value of attribute parsed_data.
Instance Method Summary collapse
-
#initialize(input) ⇒ StringParser
constructor
A new instance of StringParser.
- #parse ⇒ Object
- #to_hash ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(input) ⇒ StringParser
Returns a new instance of StringParser.
8 9 10 11 |
# File 'lib/artificial/parsers/string_parser.rb', line 8 def initialize(input) @input = input @parsed_data = {} end |
Instance Attribute Details
#input ⇒ Object (readonly)
Returns the value of attribute input.
6 7 8 |
# File 'lib/artificial/parsers/string_parser.rb', line 6 def input @input end |
#parsed_data ⇒ Object (readonly)
Returns the value of attribute parsed_data.
6 7 8 |
# File 'lib/artificial/parsers/string_parser.rb', line 6 def parsed_data @parsed_data end |
Instance Method Details
#parse ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/artificial/parsers/string_parser.rb', line 13 def parse @parsed_data = { text: @input, format: 'string', type: 'simple_text' } self end |
#to_hash ⇒ Object
26 27 28 |
# File 'lib/artificial/parsers/string_parser.rb', line 26 def to_hash @parsed_data end |
#valid? ⇒ Boolean
22 23 24 |
# File 'lib/artificial/parsers/string_parser.rb', line 22 def valid? @input.is_a?(String) && !@input.empty? end |