Class: Kalculator::TypeSources
- Inherits:
-
Object
- Object
- Kalculator::TypeSources
- Defined in:
- lib/kalculator/type_sources.rb
Instance Method Summary collapse
- #[](name) ⇒ Object
-
#initialize(*sources) ⇒ TypeSources
constructor
sources is an array of Hashes.
- #key?(name) ⇒ Boolean
-
#toHash ⇒ Object
returns a hash of variable name to type of variable.
Constructor Details
#initialize(*sources) ⇒ TypeSources
sources is an array of Hashes
9 10 11 |
# File 'lib/kalculator/type_sources.rb', line 9 def initialize(*sources)# sources is an array of Hashes @sources = sources end |
Instance Method Details
#[](name) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/kalculator/type_sources.rb', line 21 def [](name) ret = nil @sources.each do |source| break ret = source[name] if source.key?(name) end ret end |
#key?(name) ⇒ Boolean
13 14 15 16 17 18 19 |
# File 'lib/kalculator/type_sources.rb', line 13 def key?(name) ret = false @sources.each do |source| break ret = true if source.key?(name) end ret end |
#toHash ⇒ Object
returns a hash of variable name to type of variable
30 31 32 33 34 |
# File 'lib/kalculator/type_sources.rb', line 30 def toHash a = Hash.new @sources.each { |i| a = a.merge(i)} return a end |