Class: RideTheStreetcar::DSL
- Inherits:
-
Object
- Object
- RideTheStreetcar::DSL
- Includes:
- StatementsList, Streamlined::Renderable
- Defined in:
- lib/ride_the_streetcar/dsl.rb
Instance Method Summary collapse
-
#ride(start_transition: false) {|| ... } ⇒ String
Write your Streetcar logic within a block using the DSL.
- #statements ⇒ Object
-
#template ⇒ Object
rubocop:disable Style/IfUnlessModifier.
Methods included from StatementsList
#[], #apply, #console, #custom, #js, #navigate, #query_selector, #query_selector_all, #set_property
Instance Method Details
#ride(start_transition: false) {|| ... } ⇒ String
Write your Streetcar logic within a block using the DSL
15 16 17 18 19 20 |
# File 'lib/ride_the_streetcar/dsl.rb', line 15 def ride(start_transition: false, &block) @start_transition = start_transition block.arity == 1 ? yield(self) : instance_exec(&block) template.to_s.strip.tap { @statements.clear } end |
#statements ⇒ Object
8 |
# File 'lib/ride_the_streetcar/dsl.rb', line 8 def statements = @statements ||= [] |
#template ⇒ Object
rubocop:disable Style/IfUnlessModifier
23 24 25 26 27 28 |
# File 'lib/ride_the_streetcar/dsl.rb', line 23 def template html->{ <<~HTML <sc-line#{text -> { " start-transition" } if @start_transition}>#{html_map(statements) { |statement| render(statement) }}</sc-line> HTML } end |