Class: Wood::Types::CompoundType

Inherits:
Object
  • Object
show all
Includes:
TypeMatching
Defined in:
lib/wood/types.rb

Direct Known Subclasses

Array

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from TypeMatching

included

Constructor Details

#initialize(type) ⇒ CompoundType

Returns a new instance of CompoundType.



19
20
21
# File 'lib/wood/types.rb', line 19

def initialize(type)
  @type = type
end

Instance Attribute Details

#typeObject

Returns the value of attribute type.



18
19
20
# File 'lib/wood/types.rb', line 18

def type
  @type
end

Class Method Details

.[](type) ⇒ Object



14
15
16
# File 'lib/wood/types.rb', line 14

def self.[](type)
  new(type)
end

Instance Method Details

#==(other) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/wood/types.rb', line 23

def == other
  case other
  when self.class
    return type == other.type
  else
    return false
  end
end

#builtin?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/wood/types.rb', line 36

def builtin?
  type && type.builtin?
end

#numeric?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/wood/types.rb', line 32

def numeric?
  false
end

#zero_valueObject



40
41
42
# File 'lib/wood/types.rb', line 40

def zero_value
  @zero_value ||= Wood::Nodes::Null.new
end