Class: RedShift::TransitionSyntax::EventBlockParser

Inherits:
Object
  • Object
show all
Defined in:
lib/redshift/syntax.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(block) ⇒ EventBlockParser

Returns a new instance of EventBlockParser.



307
308
309
310
# File 'lib/redshift/syntax.rb', line 307

def initialize(block)
  @events = []
  instance_eval(&block)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(event_name, *args, &bl) ⇒ Object



295
296
297
298
299
300
301
302
303
304
305
# File 'lib/redshift/syntax.rb', line 295

def method_missing event_name, *args, &bl
  if args.size > 1 or (args.size == 1 and bl)
    raise SyntaxError, "Too many arguments in event specifier"
  end
  
  item = Component::EventPhaseItem.new
  item.event = event_name
  item.value = bl || (args.size > 0 && args[0]) || true

  @events << item
end

Instance Attribute Details

#eventsObject (readonly)

Returns the value of attribute events.



293
294
295
# File 'lib/redshift/syntax.rb', line 293

def events
  @events
end

Instance Method Details

#literal(val) ⇒ Object



312
313
314
# File 'lib/redshift/syntax.rb', line 312

def literal val
  Component.literal val
end