Class: TestML::Str

Inherits:
Object show all
Defined in:
lib/testml/runtime.rb

Overview


Instance Attribute Summary

Attributes inherited from Object

#value

Instance Method Summary collapse

Methods inherited from Object

#none, #type

Constructor Details

#initialize(str) ⇒ Str

Returns a new instance of Str.



409
410
411
# File 'lib/testml/runtime.rb', line 409

def initialize(str)
  @value = str.to_s
end

Instance Method Details

#boolObject



418
419
420
# File 'lib/testml/runtime.rb', line 418

def bool
  !@value.empty? ? TestML::Constant::True : TestML::Constant::False
end

#listObject



421
422
423
# File 'lib/testml/runtime.rb', line 421

def list
  TestML::List.new(@value.split //)
end

#numObject



415
416
417
# File 'lib/testml/runtime.rb', line 415

def num
  TestML::Num.new(@value =~ /^-?\d+(?:\.\d+)$/ ? $1.to_i : 0)
end

#strObject



412
413
414
# File 'lib/testml/runtime.rb', line 412

def str
  self
end