Class: Twostroke::Runtime::Types::RegExp
- Defined in:
- lib/twostroke/runtime/types/regexp.rb
Instance Attribute Summary collapse
-
#global ⇒ Object
readonly
Returns the value of attribute global.
-
#regexp ⇒ Object
readonly
Returns the value of attribute regexp.
Attributes inherited from Object
#_class, #data, #extensible, #prototype
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(regexp_source, options) ⇒ RegExp
constructor
A new instance of RegExp.
- #primitive_value ⇒ Object
Methods inherited from Object
#can_put, #construct, #constructing?, #default_value, #define_own_property, #delete, #delete!, #each_enumerable_property, #generic_items, #get, #get_own_property, #get_property, #has_accessor, #has_own_property, #has_property, #proto_put, #put, set_global_prototype, #typeof
Methods inherited from Value
Constructor Details
#initialize(regexp_source, options) ⇒ RegExp
Returns a new instance of RegExp.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/twostroke/runtime/types/regexp.rb', line 12 def initialize(regexp_source, ) opts = 0 ( ||= "").each_char do |opt| opts |= case opt when "m"; Regexp::MULTILINE when "i"; Regexp::IGNORECASE else; 0 end end @regexp = Regexp.new regexp_source, opts @global = .include? "g" @prototype = RegExp.constructor_function.get("prototype") super() end |
Instance Attribute Details
#global ⇒ Object (readonly)
Returns the value of attribute global.
11 12 13 |
# File 'lib/twostroke/runtime/types/regexp.rb', line 11 def global @global end |
#regexp ⇒ Object (readonly)
Returns the value of attribute regexp.
10 11 12 |
# File 'lib/twostroke/runtime/types/regexp.rb', line 10 def regexp @regexp end |
Class Method Details
.constructor_function ⇒ Object
3 4 5 6 7 8 |
# File 'lib/twostroke/runtime/types/regexp.rb', line 3 def self.constructor_function @@constructor_function ||= Function.new(->(scope, this, args) { RegExp.new Twostroke::Runtime::Types.to_string(args[0] || Undefined.new).string, args[1] && Twostroke::Runtime::Types.to_string(args[1]).string }, nil, "RegExp", []) end |