Class: Dhallish::Types::Record
- Inherits:
-
Object
- Object
- Dhallish::Types::Record
- Defined in:
- lib/types.rb
Instance Attribute Summary collapse
-
#types ⇒ Object
Hash: keyname -> type.
Instance Method Summary collapse
- #==(otype) ⇒ Object
-
#initialize(types) ⇒ Record
constructor
A new instance of Record.
- #to_s ⇒ Object
Constructor Details
#initialize(types) ⇒ Record
Returns a new instance of Record.
56 57 58 |
# File 'lib/types.rb', line 56 def initialize(types) @types = types end |
Instance Attribute Details
#types ⇒ Object
Hash: keyname -> type
55 56 57 |
# File 'lib/types.rb', line 55 def types @types end |
Instance Method Details
#==(otype) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/types.rb', line 60 def ==(otype) if !otype.is_a? Record or @types.size != otype.types.size return false end @types.keys.reduce(true) { |isequal, key| if !isequal or !(otype.types.key? key) false else otype.types[key] == @types[key] end } end |
#to_s ⇒ Object
74 75 76 77 78 |
# File 'lib/types.rb', line 74 def to_s() "{ #{@types.keys.map { |key| "#{key}: #{@types[key].to_s}" }.join(", ")} }" end |