Class: Stupidedi::Reader::SegmentDict

Inherits:
Object
  • Object
show all
Includes:
Inspect
Defined in:
lib/stupidedi/reader/segment_dict.rb

Direct Known Subclasses

NonEmpty

Defined Under Namespace

Classes: Constants, NonEmpty

Constant Summary collapse

Empty =
Class.new(SegmentDict) do
  def top
    raise TypeError, "empty stack"
  end

  def pop
    raise TypeError, "stack underflow"
  end

  def push(top)
    if top.is_a?(Module)
      NonEmpty.new(Constants.new(top), self)
    else
      NonEmpty.new(top, self)
    end
  end

  def defined_at?(segment_id)
    false
  end

  def at(segment_id)
    raise TypeError, "empty stack"
  end

  def empty?
    true
  end

  # @return [void]
  def pretty_print(q)
    q.text "SegmentDict.empty"
  end
end.new

Constructors collapse

Instance Method Summary collapse

Methods included from Inspect

#inspect

Class Method Details

.build(top) ⇒ SegmentDict::NonEmpty



163
164
165
# File 'lib/stupidedi/reader/segment_dict.rb', line 163

def build(top)
  SegmentDict::Empty.push(top)
end

.emptySegmentDict::Empty

Returns:



158
159
160
# File 'lib/stupidedi/reader/segment_dict.rb', line 158

def empty
  SegmentDict::Empty
end

Instance Method Details

#popSegmentDict

Return the remainder of the stack. This will throw an exception if the stack is #empty?

Returns:



15
# File 'lib/stupidedi/reader/segment_dict.rb', line 15

abstract :pop

#pushSegmentDict

Returns a new SegmentDict with top pushed to the top of the stack

Returns:



20
# File 'lib/stupidedi/reader/segment_dict.rb', line 20

abstract :push, :args => %w(top)