Class: Qipowl::Yaml
Overview
Markup processor for Yaml.
This class produces hash from YAML file.
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Class Method Summary collapse
Instance Method Summary collapse
- #harvest(callee, str) ⇒ Object
-
#initialize(file = nil) ⇒ Yaml
constructor
A new instance of Yaml.
- #parse_and_roll(str) ⇒ Object
-
#-(*args) ⇒ Object
Array element handler.
-
#:(*args) ⇒ Object
Tupla handler.
Constructor Details
#initialize(file = nil) ⇒ Yaml
Returns a new instance of Yaml.
12 13 14 15 |
# File 'lib/qipowl/bowlers/yaml.rb', line 12 def initialize file = nil super merge_rules file if file end |
Instance Attribute Details
#result ⇒ Object (readonly)
Returns the value of attribute result.
11 12 13 |
# File 'lib/qipowl/bowlers/yaml.rb', line 11 def result @result end |
Class Method Details
.parse(str) ⇒ Object
57 58 59 |
# File 'lib/qipowl/bowlers/yaml.rb', line 57 def self.parse str Yaml.new.parse_and_roll str end |
Instance Method Details
#harvest(callee, str) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/qipowl/bowlers/yaml.rb', line 41 def harvest callee, str if Hash === @partial if str == String::CARRIAGE_RETURN key = @partial.keys.last @partial.delete key @result[key] = @partial else @result.merge! @partial end else @result[str] = @partial unless str.vacant? end @partial = nil end |
#parse_and_roll(str) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/qipowl/bowlers/yaml.rb', line 17 def parse_and_roll str @result = {} @partial = nil super str @result end |
#-(*args) ⇒ Object
Array element handler
36 37 38 39 |
# File 'lib/qipowl/bowlers/yaml.rb', line 36 def |
#:(*args) ⇒ Object
Tupla handler
25 26 27 28 29 30 31 32 33 |
# File 'lib/qipowl/bowlers/yaml.rb', line 25 def |