Class: Parsable::Parser
- Inherits:
-
Object
- Object
- Parsable::Parser
- Defined in:
- lib/parsable/parser.rb
Constant Summary collapse
- REGEX =
/\{{2}(\w*\.?\S[^\{\{]*?)\}{2}/
Instance Attribute Summary collapse
-
#original_string ⇒ Object
Returns the value of attribute original_string.
-
#strings ⇒ Object
writeonly
Sets the attribute strings.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Parser
Returns a new instance of Parser.
8 9 10 |
# File 'lib/parsable/parser.rb', line 8 def initialize args={} @original_string = args.fetch(:string).to_s end |
Instance Attribute Details
#original_string ⇒ Object
Returns the value of attribute original_string.
6 7 8 |
# File 'lib/parsable/parser.rb', line 6 def original_string @original_string end |
#strings=(value) ⇒ Object
Sets the attribute strings
6 7 8 |
# File 'lib/parsable/parser.rb', line 6 def strings=(value) @strings = value end |
Instance Method Details
#parse ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/parsable/parser.rb', line 12 def parse strings.map do |string| object, attribute = capture(string) Parsable::ParsedItem.new(\ :original => string, :object => object, :attribute => attribute ) end end |