Class: CType::Primitive
- Inherits:
-
Object
- Object
- CType::Primitive
- Defined in:
- lib/caphir/ctype.rb
Overview
Enum
Constant Summary collapse
- PRIMITIVES =
{}
Class Method Summary collapse
Instance Method Summary collapse
- #evaluate(identifier) ⇒ Object
-
#initialize(val) ⇒ Primitive
constructor
A new instance of Primitive.
- #to_init_s(ident = nil) ⇒ Object
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 |