Class: CType::Primitive

Inherits:
Object
  • Object
show all
Defined in:
lib/caphir/ctype.rb

Overview

Enum

Constant Summary collapse

PRIMITIVES =
{}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(val) ⇒ Primitive

Returns a new instance of Primitive.



238
239
240
# File 'lib/caphir/ctype.rb', line 238

def initialize(val)
  @p = val.frozen? ? val : val.dup.freeze
end

Class Method Details

.[](val) ⇒ Object



259
260
261
# File 'lib/caphir/ctype.rb', line 259

def Primitive.[](val)
  PRIMITIVES[val] || self.new(val)
end

Instance Method Details

#evaluate(identifier) ⇒ Object



263
264
265
266
# File 'lib/caphir/ctype.rb', line 263

def evaluate(identifier)
  CType.evaluation_error(identifier) unless identifier.empty?
  self
end

#to_init_s(ident = nil) ⇒ Object



267
268
269
270
271
272
273
# File 'lib/caphir/ctype.rb', line 267

def to_init_s(ident=nil)
  if ident
    "#{@p} #{ident}"
  else
    @p
  end
end