Class: Interscript::Node::Item::Repeat
- Inherits:
-
Interscript::Node::Item
- Object
- Interscript::Node
- Interscript::Node::Item
- Interscript::Node::Item::Repeat
- Defined in:
- lib/interscript/visualize/nodes.rb,
lib/interscript/node/item/repeat.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
Attributes inherited from Interscript::Node::Item
Instance Method Summary collapse
- #==(other) ⇒ Object
- #first_string ⇒ Object
-
#initialize(data) ⇒ Repeat
constructor
A new instance of Repeat.
- #inspect ⇒ Object
- #max_length ⇒ Object
- #nth_string ⇒ Object
- #to_hash ⇒ Object
- #to_html(doc) ⇒ Object
Methods inherited from Interscript::Node::Item
Constructor Details
#initialize(data) ⇒ Repeat
Returns a new instance of Repeat.
3 4 5 6 |
# File 'lib/interscript/node/item/repeat.rb', line 3 def initialize data data = Interscript::Node::Item.try_convert(data) @data = data end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
2 3 4 |
# File 'lib/interscript/node/item/repeat.rb', line 2 def data @data end |
Instance Method Details
#==(other) ⇒ Object
25 26 27 |
# File 'lib/interscript/node/item/repeat.rb', line 25 def ==(other) super && self.data == other.data end |
#first_string ⇒ Object
8 9 10 |
# File 'lib/interscript/node/item/repeat.rb', line 8 def first_string data.first_string end |
#inspect ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/interscript/node/item/repeat.rb', line 29 def inspect str = case self when Interscript::Node::Item::Maybe "maybe" when Interscript::Node::Item::MaybeSome "maybe_some" when Interscript::Node::Item::Some "some" end "#{str}(#{@data.inspect})" end |
#max_length ⇒ Object
16 17 18 |
# File 'lib/interscript/node/item/repeat.rb', line 16 def max_length data.max_length end |
#nth_string ⇒ Object
12 13 14 |
# File 'lib/interscript/node/item/repeat.rb', line 12 def nth_string data.nth_string end |
#to_hash ⇒ Object
20 21 22 23 |
# File 'lib/interscript/node/item/repeat.rb', line 20 def to_hash { :class => self.class.to_s, :data => self.data.to_hash } end |
#to_html(doc) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/interscript/visualize/nodes.rb', line 64 def to_html(doc) str = case self when Interscript::Node::Item::Maybe "zero or one " when Interscript::Node::Item::MaybeSome "zero or more of " when Interscript::Node::Item::Some "one or more of " end "<nobr>#{str}(</nobr>#{@data.to_html(doc)})" end |