Class: Wood::Types::BuiltinType

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

Direct Known Subclasses

AnyType, BooleanType, NumericType

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from TypeMatching

included

Constructor Details

#initialize(name, numeric = false, *aliases) ⇒ BuiltinType

Returns a new instance of BuiltinType.



172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/wood/types.rb', line 172

def initialize(name, numeric = false, *aliases)
  super(name)

  @aliases = aliases
  @numeric = numeric

  if numeric?
    Types::NUMERIC_TYPES << self
  else
    Types::NON_NUMERIC_TYPES << self
  end
end

Instance Attribute Details

#aliasesObject (readonly)

Returns the value of attribute aliases.



170
171
172
# File 'lib/wood/types.rb', line 170

def aliases
  @aliases
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



168
169
170
# File 'lib/wood/types.rb', line 168

def name
  @name
end

#zero_valueObject

Returns the value of attribute zero_value.



171
172
173
# File 'lib/wood/types.rb', line 171

def zero_value
  @zero_value
end

Instance Method Details

#==(other) ⇒ Object



201
202
203
204
205
206
207
208
# File 'lib/wood/types.rb', line 201

def == other
  case other
  when BuiltinType
    return name == other.name
  else
    return false
  end
end

#builtin?Boolean

Returns:

  • (Boolean)


189
190
191
# File 'lib/wood/types.rb', line 189

def builtin?
  true
end

#node_nameObject



197
198
199
# File 'lib/wood/types.rb', line 197

def node_name
  (Array(name).map(&:to_s).join("_") + "_type").snake_cased.to_sym
end

#numeric?Boolean

Returns:

  • (Boolean)


185
186
187
# File 'lib/wood/types.rb', line 185

def numeric?
  @numeric
end

#sexpObject



193
194
195
# File 'lib/wood/types.rb', line 193

def sexp
  name
end

#typeObject



210
211
212
# File 'lib/wood/types.rb', line 210

def type
  self
end