Class: Wood::Types::CustomType

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from TypeMatching

included

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



163
164
165
# File 'lib/wood/types.rb', line 163

def method_missing(method, *args)
  type.__send__(method, *args)
end

Instance Attribute Details

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



110
111
112
# File 'lib/wood/types.rb', line 110

def type
  @type
end

Class Method Details

.[](type) ⇒ Object



112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/wood/types.rb', line 112

def self.[](type)
  case type
  when BuiltinType
    return type
  when CustomType
    return type
  when CompoundType
    return type
  else
    new(type)
  end
end

Instance Method Details

#==(other) ⇒ Object



133
134
135
136
137
138
139
140
# File 'lib/wood/types.rb', line 133

def == other
  case other
  when CustomType
    return type == other.type
  else
    return type == other
  end
end

#===(other) ⇒ Object



142
143
144
145
146
147
148
149
# File 'lib/wood/types.rb', line 142

def === other
  case other
  when CustomType
    return type === other.type
  else
    return type === other
  end
end

#builtin?Boolean

Returns:

  • (Boolean)


155
156
157
# File 'lib/wood/types.rb', line 155

def builtin?
  false
end

#nameObject



159
160
161
# File 'lib/wood/types.rb', line 159

def name
  type.name
end

#node_nameObject



125
126
127
# File 'lib/wood/types.rb', line 125

def node_name
  :custom_type
end

#numeric?Boolean

Returns:

  • (Boolean)


151
152
153
# File 'lib/wood/types.rb', line 151

def numeric?
  false
end

#sexpObject



129
130
131
# File 'lib/wood/types.rb', line 129

def sexp
  [:custom_type, type.sexp]
end