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