Class: SpinningCursor::Parser
- Inherits:
-
Object
- Object
- SpinningCursor::Parser
- Defined in:
- lib/spinning_cursor/parser.rb
Instance Attribute Summary collapse
-
#outer_scope_object ⇒ Object
Returns the value of attribute outer_scope_object.
Instance Method Summary collapse
-
#action(&block) ⇒ Object
Getter and setter for the action block.
-
#banner(banner) ⇒ Object
Getters and setters for
banner,type,message,delayandoutputattributes. -
#delay(delay) ⇒ Object
Getters and setters for
banner,type,message,delayandoutputattributes. -
#initialize(&block) ⇒ Parser
constructor
Parses proc.
-
#message(message) ⇒ Object
Getters and setters for
banner,type,message,delayandoutputattributes. -
#output(output) ⇒ Object
Getters and setters for
banner,type,message,delayandoutputattributes. -
#type(type) ⇒ Object
Getters and setters for
banner,type,message,delayandoutputattributes.
Constructor Details
#initialize(&block) ⇒ Parser
Parses proc
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/spinning_cursor/parser.rb', line 8 def initialize(&block) @banner = "Loading" @type = :spinner @message = "Done" @delay = nil @action = nil @output = :inline if block_given? @outer_scope_object = eval("self", block.binding) instance_eval &block end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object (private)
Pass any other methods to the calling class
56 57 58 |
# File 'lib/spinning_cursor/parser.rb', line 56 def method_missing(method, *args, &block) @outer_scope_object.send method, *args, &block end |
Instance Attribute Details
#outer_scope_object ⇒ Object
Returns the value of attribute outer_scope_object.
3 4 5 |
# File 'lib/spinning_cursor/parser.rb', line 3 def outer_scope_object @outer_scope_object end |
Instance Method Details
#action(&block) ⇒ Object
Getter and setter for the action block
25 26 27 28 29 |
# File 'lib/spinning_cursor/parser.rb', line 25 def action(&block) @action = block if block @action end |
#banner(banner) ⇒ Object
For getting, use method without arguments
e.g. banner
For setting, use method with arguments
e.g. banner "my banner"
Getters and setters for banner, type, message, delay and output
attributes
43 44 45 46 47 48 49 |
# File 'lib/spinning_cursor/parser.rb', line 43 %w[banner type message delay output].each do |method| define_method(method) do |*args| var = "@#{method}" return instance_variable_get(var) unless args.first instance_variable_set(var, args.first) end end |
#delay(delay) ⇒ Object
For getting, use method without arguments
e.g. banner
For setting, use method with arguments
e.g. banner "my banner"
Getters and setters for banner, type, message, delay and output
attributes
43 44 45 46 47 48 49 |
# File 'lib/spinning_cursor/parser.rb', line 43 %w[banner type message delay output].each do |method| define_method(method) do |*args| var = "@#{method}" return instance_variable_get(var) unless args.first instance_variable_set(var, args.first) end end |
#message(message) ⇒ Object
For getting, use method without arguments
e.g. banner
For setting, use method with arguments
e.g. banner "my banner"
Getters and setters for banner, type, message, delay and output
attributes
43 44 45 46 47 48 49 |
# File 'lib/spinning_cursor/parser.rb', line 43 %w[banner type message delay output].each do |method| define_method(method) do |*args| var = "@#{method}" return instance_variable_get(var) unless args.first instance_variable_set(var, args.first) end end |
#output(output) ⇒ Object
For getting, use method without arguments
e.g. banner
For setting, use method with arguments
e.g. banner "my banner"
Getters and setters for banner, type, message, delay and output
attributes
43 44 45 46 47 48 49 |
# File 'lib/spinning_cursor/parser.rb', line 43 %w[banner type message delay output].each do |method| define_method(method) do |*args| var = "@#{method}" return instance_variable_get(var) unless args.first instance_variable_set(var, args.first) end end |
#type(type) ⇒ Object
For getting, use method without arguments
e.g. banner
For setting, use method with arguments
e.g. banner "my banner"
Getters and setters for banner, type, message, delay and output
attributes
43 44 45 46 47 48 49 |
# File 'lib/spinning_cursor/parser.rb', line 43 %w[banner type message delay output].each do |method| define_method(method) do |*args| var = "@#{method}" return instance_variable_get(var) unless args.first instance_variable_set(var, args.first) end end |