Class: Stupidedi::Reader::SegmentDict::NonEmpty
- Inherits:
-
Stupidedi::Reader::SegmentDict
- Object
- Stupidedi::Reader::SegmentDict
- Stupidedi::Reader::SegmentDict::NonEmpty
- Defined in:
- lib/stupidedi/reader/segment_dict.rb
Constant Summary
Constants inherited from Stupidedi::Reader::SegmentDict
Instance Attribute Summary collapse
- #pop ⇒ SegmentDict readonly
-
#top ⇒ Object
readonly
Returns the value of attribute top.
Instance Method Summary collapse
- #at(segment_id) ⇒ Object
- #copy(changes = {}) ⇒ SegmentDict
- #defined_at?(segment_id) ⇒ Boolean
- #empty? ⇒ Boolean
-
#initialize(top, pop = SegmentDict.empty) ⇒ NonEmpty
constructor
A new instance of NonEmpty.
- #pretty_print(q) ⇒ void
- #push(top) ⇒ Object
Methods inherited from Stupidedi::Reader::SegmentDict
Methods included from Inspect
Constructor Details
#initialize(top, pop = SegmentDict.empty) ⇒ NonEmpty
Returns a new instance of NonEmpty.
39 40 41 |
# File 'lib/stupidedi/reader/segment_dict.rb', line 39 def initialize(top, pop = SegmentDict.empty) @top, @pop = top, pop end |
Instance Attribute Details
#pop ⇒ SegmentDict (readonly)
37 38 39 |
# File 'lib/stupidedi/reader/segment_dict.rb', line 37 def pop @pop end |
#top ⇒ Object (readonly)
Returns the value of attribute top.
34 35 36 |
# File 'lib/stupidedi/reader/segment_dict.rb', line 34 def top @top end |
Instance Method Details
#at(segment_id) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/stupidedi/reader/segment_dict.rb', line 58 def at(segment_id) if @top.defined_at?(segment_id) @top.at(segment_id) else @pop.at(segment_id) end end |
#copy(changes = {}) ⇒ SegmentDict
44 45 46 47 48 |
# File 'lib/stupidedi/reader/segment_dict.rb', line 44 def copy(changes = {}) NonEmpty.new \ changes.fetch(:top, @top), changes.fetch(:pop, @pop) end |
#defined_at?(segment_id) ⇒ Boolean
66 67 68 69 |
# File 'lib/stupidedi/reader/segment_dict.rb', line 66 def defined_at?(segment_id) @top.defined_at?(segment_id) or @pop.defined_at?(segment_id) end |
#empty? ⇒ Boolean
71 72 73 |
# File 'lib/stupidedi/reader/segment_dict.rb', line 71 def empty? false end |
#pretty_print(q) ⇒ void
This method returns an undefined value.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/stupidedi/reader/segment_dict.rb', line 76 def pretty_print(q) q.text "SegmentDict" q.group(2, "(", ")") do q.breakable "" node = self until node.empty? unless q.current_group.first? q.text "," q.breakable end q.pp node.top node = node.pop end end end |