Module: Ryo::Keywords
- Included in:
- Ryo
- Defined in:
- lib/ryo/keywords.rb
Overview
The Ryo::Keywords module implements Ryo equivalents for some of JavaScript’s keywords (eg: the in and delete operators). The instance methods of this module are available as singleton methods on the Ryo module.
Instance Method Summary collapse
-
#fn(&b) ⇒ Ryo::Function
(also: #function)
Returns a Ryo function.
-
#in?(ryo, property) ⇒ Boolean
Equivalent to JavaScript’s in operator.
-
#delete(ryo, property, ancestors: nil) ⇒ void
The #delete method deletes a property from a Ryo object.
Instance Method Details
#fn(&b) ⇒ Ryo::Function Also known as: function
Returns a Ryo function.
21 22 23 |
# File 'lib/ryo/keywords.rb', line 21 def fn(&b) Ryo::Function.new(&b) end |
#in?(ryo, property) ⇒ Boolean
Equivalent to JavaScript’s in operator
34 35 36 37 |
# File 'lib/ryo/keywords.rb', line 34 def in?(ryo, property) return false unless ryo property?(ryo, property) || in?(prototype_of(ryo), property) end |
#delete(ryo, property, ancestors: nil) ⇒ void
This method returns an undefined value.
The #delete method deletes a property from a Ryo object
50 51 52 53 54 |
# File 'lib/ryo/keywords.rb', line 50 def delete(ryo, property, ancestors: nil) each_ryo(ryo, ancestors:) do Ryo.property?(_1, property) ? table_of(_1).delete(property) : nil end end |