Class: Stupidedi::Reader::SegmentDict::Constants

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

Instance Method Summary collapse

Constructor Details

#initialize(namespace) ⇒ Constants

Returns a new instance of Constants.



132
133
134
135
136
# File 'lib/stupidedi/reader/segment_dict.rb', line 132

def initialize(namespace)
  @namespace = namespace
  @constants = Hash.new
  namespace.constants.each{|c| @constants[c.to_sym] = true }
end

Instance Method Details

#at(segment_id) ⇒ Object



138
139
140
# File 'lib/stupidedi/reader/segment_dict.rb', line 138

def at(segment_id)
  @namespace.const_get(segment_id)
end

#defined_at?(segment_id) ⇒ Boolean

Returns:

  • (Boolean)


142
143
144
# File 'lib/stupidedi/reader/segment_dict.rb', line 142

def defined_at?(segment_id)
  @constants.include?(segment_id.to_sym)
end

#pretty_print(q) ⇒ void

This method returns an undefined value.



147
148
149
# File 'lib/stupidedi/reader/segment_dict.rb', line 147

def pretty_print(q)
  q.text("#{@namespace.name}.constants")
end