class Minjs::ECMA262::Boolean

Class of ECMA262 Boolean element

@see www.ecma-international.org/ecma-262 ECMA262 7.8.2

Attributes

val[R]

Public Class Methods

get(val) click to toggle source

get instance

# File lib/minjs/ecma262/literal.rb, line 379
def self.get(val)
  if val.to_sym == :true || val == true
    @@true
  else
    @@false
  end
end
new(val) click to toggle source
# File lib/minjs/ecma262/literal.rb, line 278
def initialize(val)
  if val.to_s == "true"
    @val = :"true"
  else
    @val = :"false"
  end
end

Public Instance Methods

==(obj) click to toggle source

compare object

# File lib/minjs/ecma262/literal.rb, line 300
def ==(obj)
  self.class == obj.class and
    @val == obj.val
end
deep_dup() click to toggle source

duplicate object @see Base#deep_dup

# File lib/minjs/ecma262/literal.rb, line 288
def deep_dup
  self #//not dup
end
ecma262_typeof() click to toggle source

return results of ‘typeof’ operator.

@return [Symbol] :boolean

# File lib/minjs/ecma262/literal.rb, line 371
def ecma262_typeof
  :boolean
end
left_hand_side_exp?() click to toggle source

@return [Boolean] true if expression is kind of LeftHandSideExpression.

# File lib/minjs/ecma262/literal.rb, line 312
def left_hand_side_exp?
  true
end
to_ecma262_boolean() click to toggle source

Returns results of ToBoolean()

Returns true or false if trivial, otherwise nil.

@return [Boolean]

@see www.ecma-international.org/ecma-262 ECMA262 9.2

# File lib/minjs/ecma262/literal.rb, line 344
def to_ecma262_boolean
  if @val == :false
    false
  else
    true
  end
end
to_ecma262_number() click to toggle source

Returns results of ToNumber()

Returns number if value is trivial, otherwise nil.

@return [Numeric]

@see www.ecma-international.org/ecma-262 ECMA262 9.3

# File lib/minjs/ecma262/literal.rb, line 360
def to_ecma262_number
  if @val == :false
    0
  else
    1
  end
end
to_ecma262_string() click to toggle source

Returns results of ToString()

Returns string if value is trivial, otherwise nil.

@return [Numeric]

@see www.ecma-international.org/ecma-262 ECMA262 9.8

# File lib/minjs/ecma262/literal.rb, line 328
def to_ecma262_string
  if @val == :false
    "false"
  else
    "true"
  end
end
to_js(options = {}) click to toggle source

Returns a ECMAScript string containg the representation of element. @see Base#to_js

# File lib/minjs/ecma262/literal.rb, line 307
def to_js(options = {})
  @val.to_s
end
traverse(parent) { |parent, self| ... } click to toggle source

Traverses this children and itself with given block.

@see Base#traverse

# File lib/minjs/ecma262/literal.rb, line 295
def traverse(parent, &block)
  yield parent, self
end
true?() click to toggle source
# File lib/minjs/ecma262/literal.rb, line 316
def true?
  @val == :true
end