Class: Annal::Parse
- Inherits:
-
Object
- Object
- Annal::Parse
- Defined in:
- lib/annal/parse.rb
Instance Attribute Summary collapse
-
#raw_data ⇒ Object
Returns the value of attribute raw_data.
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(raw_data) ⇒ Parse
constructor
A new instance of Parse.
-
#parse_yaml ⇒ Object
Also parses JSON.
- #parseable? ⇒ Boolean
Constructor Details
#initialize(raw_data) ⇒ Parse
Returns a new instance of Parse.
6 7 8 |
# File 'lib/annal/parse.rb', line 6 def initialize(raw_data) self.raw_data = raw_data end |
Instance Attribute Details
#raw_data ⇒ Object
Returns the value of attribute raw_data.
5 6 7 |
# File 'lib/annal/parse.rb', line 5 def raw_data @raw_data end |
Instance Method Details
#data ⇒ Object
10 11 12 |
# File 'lib/annal/parse.rb', line 10 def data @data ||= parse_yaml end |
#parse_yaml ⇒ Object
Also parses JSON
19 20 21 22 23 24 25 |
# File 'lib/annal/parse.rb', line 19 def parse_yaml begin YAML.load(raw_data) rescue Psych::SyntaxError raw_data end end |
#parseable? ⇒ Boolean
14 15 16 |
# File 'lib/annal/parse.rb', line 14 def parseable? not data.kind_of?(String) end |