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.
41 42 43 |
# File 'lib/stupidedi/reader/segment_dict.rb', line 41 def initialize(top, pop = SegmentDict.empty) @top, @pop = top, pop end |
Instance Attribute Details
#pop ⇒ SegmentDict (readonly)
39 40 41 |
# File 'lib/stupidedi/reader/segment_dict.rb', line 39 def pop @pop end |
#top ⇒ Object (readonly)
Returns the value of attribute top.
36 37 38 |
# File 'lib/stupidedi/reader/segment_dict.rb', line 36 def top @top end |
Instance Method Details
#at(segment_id) ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/stupidedi/reader/segment_dict.rb', line 60 def at(segment_id) if @top.defined_at?(segment_id) @top.at(segment_id) else @pop.at(segment_id) end end |
#copy(changes = {}) ⇒ SegmentDict
46 47 48 49 50 |
# File 'lib/stupidedi/reader/segment_dict.rb', line 46 def copy(changes = {}) NonEmpty.new \ changes.fetch(:top, @top), changes.fetch(:pop, @pop) end |
#defined_at?(segment_id) ⇒ Boolean
68 69 70 71 |
# File 'lib/stupidedi/reader/segment_dict.rb', line 68 def defined_at?(segment_id) @top.defined_at?(segment_id) or @pop.defined_at?(segment_id) end |
#empty? ⇒ Boolean
73 74 75 |
# File 'lib/stupidedi/reader/segment_dict.rb', line 73 def empty? false end |
#pretty_print(q) ⇒ void
This method returns an undefined value.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/stupidedi/reader/segment_dict.rb', line 78 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 |