Class: Minjs::ECMA262::Punctuator

Inherits:
Literal show all
Defined in:
lib/minjs/ecma262/punctuator.rb

Overview

ECMA262 punctuator element

See Also:

Constant Summary collapse

@@sym =
{}

Instance Attribute Summary collapse

Attributes inherited from Base

#parent

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Literal

#lt?, #priority, #side_effect?, #ws?

Methods inherited from Base

#add_remove_paren, #concat, #deep_dup, #replace, #traverse

Constructor Details

#initialize(val) ⇒ Punctuator

Returns a new instance of Punctuator.



11
12
13
# File 'lib/minjs/ecma262/punctuator.rb', line 11

def initialize(val)
  @val = val.to_sym
end

Instance Attribute Details

#valObject (readonly)

Returns the value of attribute val.



7
8
9
# File 'lib/minjs/ecma262/punctuator.rb', line 7

def val
  @val
end

Class Method Details

.get(val) ⇒ Object

Returns punctuator object representation of string.

Parameters:

  • val (String)

    punctuator



18
19
20
# File 'lib/minjs/ecma262/punctuator.rb', line 18

def self.get(val)
  @@sym[val] ||= self.new(val)
end

Instance Method Details

#==(obj) ⇒ Object

Return true if punctuator equals to other.

Parameters:

  • obj

    other element.



36
37
38
# File 'lib/minjs/ecma262/punctuator.rb', line 36

def ==(obj)
  self.class == obj.class and self.val == obj.val
end

#to_jsObject

Returns a ECMAScript string containg the representation of element.

See Also:



29
30
31
# File 'lib/minjs/ecma262/punctuator.rb', line 29

def to_js
  val.to_s
end

#to_sObject

Returns a string containg the representation of punctuator.



23
24
25
# File 'lib/minjs/ecma262/punctuator.rb', line 23

def to_s
  val.to_s
end