Class: TokyoMetro::Factory::Generate::Static::MetaClass::Info::Normal

Inherits:
Fundamental
  • Object
show all
Defined in:
lib/tokyo_metro/factory/generate/static/meta_class/info/normal.rb

Instance Method Summary collapse

Methods inherited from Fundamental

#generate, info_class_for_this_class, process

Constructor Details

#initialize(same_as, h) ⇒ Normal

Returns a new instance of Normal.



3
4
5
6
7
8
9
10
11
12
# File 'lib/tokyo_metro/factory/generate/static/meta_class/info/normal.rb', line 3

def initialize( same_as , h )
  @same_as = same_as
  @h = h.with_indifferent_access
  @hash_for_making_variables = ::Hash.new.with_indifferent_access

  # puts "same_as: #{ same_as }"
  # puts "hash keys: #{ @h.keys }"

  set_values_to_hash_for_making_variables
end

Instance Method Details

#variablesObject



14
15
16
17
18
19
# File 'lib/tokyo_metro/factory/generate/static/meta_class/info/normal.rb', line 14

def variables
  # puts "variables: " + ( [ @same_as ] + variables_from_hash_keys ).to_s
  # puts "length: " + ( [ @same_as ] + variables_from_hash_keys ).length.to_s
  # puts ""
  [ @same_as ] + super
end

#variables_from_hash_keys(hash_key_array: self.class.hash_keys, info: @hash_for_making_variables) ⇒ Object Also known as: variables_from_hash_keys__alias



21
22
23
24
25
26
27
28
29
# File 'lib/tokyo_metro/factory/generate/static/meta_class/info/normal.rb', line 21

def variables_from_hash_keys( hash_key_array: self.class.hash_keys , info: @hash_for_making_variables )
  if info.nil?
    super( hash_key_array: hash_key_array )
  elsif info.kind_of?( ::Hash )
    hash_key_array.map { | key_name | info[ key_name ] }
  else
    hash_key_array.map { | key_name | info.send( key_name ) }
  end
end