Class: RideTheStreetcar::JS
- Inherits:
-
Object
- Object
- RideTheStreetcar::JS
- Includes:
- Streamlined::Renderable
- Defined in:
- lib/ride_the_streetcar/js.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#chain ⇒ Object
readonly
Returns the value of attribute chain.
Instance Method Summary collapse
-
#initialize ⇒ JS
constructor
A new instance of JS.
-
#method_missing(method_name, *args) ⇒ Object
rubocop:disable Style/MissingRespondToMissing.
- #set_property? ⇒ Boolean
- #template ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ JS
Returns a new instance of JS.
10 11 12 13 |
# File 'lib/ride_the_streetcar/js.rb', line 10 def initialize @chain = [] @args = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
rubocop:disable Style/MissingRespondToMissing
15 16 17 18 19 20 |
# File 'lib/ride_the_streetcar/js.rb', line 15 def method_missing(method_name, *args) # rubocop:disable Style/MissingRespondToMissing @args = args if args.length.positive? chain << method_name self end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
8 9 10 |
# File 'lib/ride_the_streetcar/js.rb', line 8 def args @args end |
#chain ⇒ Object (readonly)
Returns the value of attribute chain.
6 7 8 |
# File 'lib/ride_the_streetcar/js.rb', line 6 def chain @chain end |
Instance Method Details
#set_property? ⇒ Boolean
22 |
# File 'lib/ride_the_streetcar/js.rb', line 22 def set_property? = chain.last.end_with?("=") |
#template ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/ride_the_streetcar/js.rb', line 28 def template if set_property? render SetProperty.new(to_s, args.first) else render Apply.new(to_s, *args) end end |
#to_s ⇒ Object
24 25 26 |
# File 'lib/ride_the_streetcar/js.rb', line 24 def to_s chain.join(".").delete_suffix("=") end |