Module: Ryo::Keywords
- Included in:
- Ryo
- Defined in:
- lib/ryo/keywords.rb
Overview
The Ryo::Keywords module implements Ryo equivalents to some of JavaScript's keywords - for example: the in and delete operators. The instance methods of this module are available as singleton methods on the Ryo module.
Instance Method Summary collapse
-
#delete(ryo, property)
The #delete method deletes a property from a Ryo object.
-
#fn(&b) ⇒ Ryo::Function
(also: #function)
Returns a Ryo function.
-
#in?(ryo, property) ⇒ Boolean
Equivalent to JavaScript's in operator.
Instance Method Details
#delete(ryo, property)
Note:
This method does not delete properties from the prototype(s)
of a Ryo object.
For that - see Ryo::Reflect#delete!.
This method returns an undefined value.
The #delete method deletes a property from a Ryo object. More or less equivalent to JavaScript's "delete" operator.
58 59 60 61 62 63 64 65 66 |
# File 'lib/ryo/keywords.rb', line 58 def delete(ryo, property) property = property.to_s if property?(ryo, property) table_of(ryo).delete(property) else return if getter_defined?(ryo, property) define_method!(ryo, property) { ryo[property] } end end |
#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.
37 38 39 40 |
# File 'lib/ryo/keywords.rb', line 37 def in?(ryo, property) return false unless ryo property?(ryo, property) || in?(prototype_of(ryo), property) end |