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.



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

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



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

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

#defined_at?(segment_id) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#pretty_print(q) ⇒ void

This method returns an undefined value.



151
152
153
# File 'lib/stupidedi/reader/segment_dict.rb', line 151

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