Class: Nyanko::Invoker::Options
- Inherits:
-
Object
- Object
- Nyanko::Invoker::Options
- Defined in:
- lib/nyanko/invoker/options.rb
Constant Summary collapse
- CANDIDATES =
{ :active_if_options => true, :as => true, :capture => true, :locals => true, :type => true, }
Instance Method Summary collapse
- #active_if_options ⇒ Object
- #as ⇒ Object
- #capture ⇒ Object
-
#initialize(*args) ⇒ Options
constructor
A new instance of Options.
- #invoke_options ⇒ Object
- #label ⇒ Object
- #locals ⇒ Object
- #options ⇒ Object
- #short_hand_options? ⇒ Boolean
- #type ⇒ Object
- #unit_name ⇒ Object
Constructor Details
#initialize(*args) ⇒ Options
Returns a new instance of Options.
12 13 14 15 |
# File 'lib/nyanko/invoker/options.rb', line 12 def initialize(*args) @raw_options = args. @args = args end |
Instance Method Details
#active_if_options ⇒ Object
29 30 31 |
# File 'lib/nyanko/invoker/options.rb', line 29 def [:active_if_options] || {} end |
#as ⇒ Object
33 34 35 |
# File 'lib/nyanko/invoker/options.rb', line 33 def as [:as] end |
#capture ⇒ Object
37 38 39 |
# File 'lib/nyanko/invoker/options.rb', line 37 def capture .has_key?(:capture) ? capture[:capture] : true end |
#invoke_options ⇒ Object
45 46 47 |
# File 'lib/nyanko/invoker/options.rb', line 45 def { :capture => capture, :type => type } end |
#label ⇒ Object
21 22 23 |
# File 'lib/nyanko/invoker/options.rb', line 21 def label @args[1] end |
#locals ⇒ Object
25 26 27 |
# File 'lib/nyanko/invoker/options.rb', line 25 def locals ([:locals] || {}).symbolize_keys end |
#options ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/nyanko/invoker/options.rb', line 49 def @options ||= begin if { :locals => @raw_options } else @raw_options end end end |
#short_hand_options? ⇒ Boolean
59 60 61 |
# File 'lib/nyanko/invoker/options.rb', line 59 def @raw_options.any? && @raw_options.keys.all? {|key| !CANDIDATES[key] } end |
#type ⇒ Object
41 42 43 |
# File 'lib/nyanko/invoker/options.rb', line 41 def type [:type] end |
#unit_name ⇒ Object
17 18 19 |
# File 'lib/nyanko/invoker/options.rb', line 17 def unit_name @args[0] end |