Class: RubyRunJs::JsRegExp
- Inherits:
-
JsBaseObject
- Object
- JsBaseObject
- RubyRunJs::JsRegExp
- Defined in:
- lib/ruby_run_js/objects/js_regexp.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#flag_global ⇒ Object
readonly
Returns the value of attribute flag_global.
-
#flag_ignore_case ⇒ Object
readonly
Returns the value of attribute flag_ignore_case.
-
#flag_multiline ⇒ Object
readonly
Returns the value of attribute flag_multiline.
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
Attributes inherited from JsBaseObject
#_class, #extensible, #own, #prototype, #value
Instance Method Summary collapse
-
#initialize(body, flags, prototype) ⇒ JsRegExp
constructor
A new instance of JsRegExp.
Methods inherited from JsBaseObject
#_type, #can_put, #default_value, #define_own_property, #delete, #get, #get_items, #get_own_property, #get_property, #has_property, #put, #set_items
Methods included from Helper
#check_object, #get_member, #get_member_dot, #is_accessor_descriptor, #is_callable, #is_data_descriptor, #is_generic_descriptor, #is_primitive, #make_error, #strict_equality
Methods included from ConversionHelper
#convert_to_js_type, #to_boolean, #to_int32, #to_integer, #to_number, #to_object, #to_primitive, #to_string, #to_uint16, #to_uint32
Constructor Details
#initialize(body, flags, prototype) ⇒ JsRegExp
Returns a new instance of JsRegExp.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/ruby_run_js/objects/js_regexp.rb', line 9 def initialize(body, flags, prototype) super() @_class = 'RegExp' @prototype = prototype @flag_global = flags.include?('g') @flag_ignore_case = flags.include?('i') ? Regexp::IGNORECASE : 0 @flag_multiline = flags.include?('m') ? Regexp::MULTILINE : 0 @body = body begin @pattern = Regexp.new(@body, @flag_ignore_case | @flag_multiline) rescue raise make_error('SyntaxError', "Invalid RegExp pattern: #{@body}") end define_own_property('source', { 'value' => @body, 'enumerable' => false, 'writable' => false, 'configurable' => false }) define_own_property('global',{ 'value' => @flag_global, 'enumerable' => false, 'writable' => false, 'configurable' => false }) define_own_property('ignoreCase',{ 'value' => @flag_ignore_case > 0, 'enumerable' => false, 'writable' => false, 'configurable' => false }) define_own_property('multiline',{ 'value' => @flag_multiline > 0, 'enumerable' => false, 'writable' => false, 'configurable' => false }) define_own_property('lastIndex',{ 'value' => 0.0, 'enumerable' => false, 'writable' => true, 'configurable' => false }) end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
7 8 9 |
# File 'lib/ruby_run_js/objects/js_regexp.rb', line 7 def body @body end |
#flag_global ⇒ Object (readonly)
Returns the value of attribute flag_global.
7 8 9 |
# File 'lib/ruby_run_js/objects/js_regexp.rb', line 7 def flag_global @flag_global end |
#flag_ignore_case ⇒ Object (readonly)
Returns the value of attribute flag_ignore_case.
7 8 9 |
# File 'lib/ruby_run_js/objects/js_regexp.rb', line 7 def flag_ignore_case @flag_ignore_case end |
#flag_multiline ⇒ Object (readonly)
Returns the value of attribute flag_multiline.
7 8 9 |
# File 'lib/ruby_run_js/objects/js_regexp.rb', line 7 def flag_multiline @flag_multiline end |
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
7 8 9 |
# File 'lib/ruby_run_js/objects/js_regexp.rb', line 7 def pattern @pattern end |