Class: IRealB::Parser
- Inherits:
-
Object
- Object
- IRealB::Parser
- Defined in:
- lib/irealb/parser.rb,
lib/irealb/parser/tune.rb,
lib/irealb/parser/chord.rb,
lib/irealb/parser/runner.rb,
lib/irealb/parser/version.rb,
lib/irealb/parser/chord_grouping.rb
Defined Under Namespace
Classes: Chord, ChordGrouping, Runner, Tune
Constant Summary collapse
- VERSION =
"0.0.1"
Instance Attribute Summary collapse
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#tunes ⇒ Object
readonly
Returns the value of attribute tunes.
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
-
#initialize(text) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
#initialize(text) ⇒ Parser
Returns a new instance of Parser.
14 15 16 17 |
# File 'lib/irealb/parser.rb', line 14 def initialize(text) @text = text @tunes = [] end |
Instance Attribute Details
#text ⇒ Object (readonly)
Returns the value of attribute text.
11 12 13 |
# File 'lib/irealb/parser.rb', line 11 def text @text end |
#tunes ⇒ Object (readonly)
Returns the value of attribute tunes.
12 13 14 |
# File 'lib/irealb/parser.rb', line 12 def tunes @tunes end |
Instance Method Details
#as_json(options = {}) ⇒ Object
28 29 30 |
# File 'lib/irealb/parser.rb', line 28 def as_json( = {}) tunes.map(&:as_json) end |
#parse ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/irealb/parser.rb', line 19 def parse @text.split("=").in_groups_of(6).each do |raw_tune| parse_tune(raw_tune).tap do |tune| @tunes << tune if tune end end self end |