Module: Belafonte::DSL::Definition
- Defined in:
- lib/belafonte/dsl/definition.rb
Overview
Class methods for defining apps
Instance Method Summary collapse
- #arg(name, arg_options = {}) ⇒ Object
- #args ⇒ Object
- #description(description) ⇒ Object
- #has_unlimited_arg? ⇒ Boolean
- #info(item) ⇒ Object
- #meta ⇒ Object
- #mount(app) ⇒ Object
- #option(name, option_options = {}) ⇒ Object
- #options ⇒ Object
- #subcommands ⇒ Object
- #summary(summary) ⇒ Object
- #switch(name, switch_options = {}) ⇒ Object
- #switches ⇒ Object
- #title(title) ⇒ Object
Instance Method Details
#arg(name, arg_options = {}) ⇒ Object
50 51 52 |
# File 'lib/belafonte/dsl/definition.rb', line 50 def arg(name, = {}) args.push(Belafonte::Argument.new(.merge({name: name}))) end |
#args ⇒ Object
46 47 48 |
# File 'lib/belafonte/dsl/definition.rb', line 46 def args [:args] ||= [] end |
#description(description) ⇒ Object
26 27 28 |
# File 'lib/belafonte/dsl/definition.rb', line 26 def description(description) [:description] = description end |
#has_unlimited_arg? ⇒ Boolean
67 68 69 |
# File 'lib/belafonte/dsl/definition.rb', line 67 def has_unlimited_arg? !(args.find {|arg| arg.unlimited?}).nil? end |
#info(item) ⇒ Object
14 15 16 |
# File 'lib/belafonte/dsl/definition.rb', line 14 def info(item) [item] end |
#meta ⇒ Object
10 11 12 |
# File 'lib/belafonte/dsl/definition.rb', line 10 def @meta ||= {} end |
#mount(app) ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'lib/belafonte/dsl/definition.rb', line 58 def mount(app) unless args.any? {|arg| arg.name.to_sym == :command} arg :command, times: :unlimited end raise Belafonte::Errors::CircularMount.new("An app cannot mount itself") if app == self subcommands.push(app) end |
#option(name, option_options = {}) ⇒ Object
42 43 44 |
# File 'lib/belafonte/dsl/definition.rb', line 42 def option(name, = {}) .push(Belafonte::Option.new(.merge({name: name}))) end |
#options ⇒ Object
38 39 40 |
# File 'lib/belafonte/dsl/definition.rb', line 38 def [:options] ||= [] end |
#subcommands ⇒ Object
54 55 56 |
# File 'lib/belafonte/dsl/definition.rb', line 54 def subcommands [:subcommands] ||= [] end |
#summary(summary) ⇒ Object
22 23 24 |
# File 'lib/belafonte/dsl/definition.rb', line 22 def summary(summary) [:summary] = summary end |
#switch(name, switch_options = {}) ⇒ Object
34 35 36 |
# File 'lib/belafonte/dsl/definition.rb', line 34 def switch(name, = {}) switches.push(Belafonte::Switch.new(.merge({name: name}))) end |
#switches ⇒ Object
30 31 32 |
# File 'lib/belafonte/dsl/definition.rb', line 30 def switches [:switches] ||= [] end |
#title(title) ⇒ Object
18 19 20 |
# File 'lib/belafonte/dsl/definition.rb', line 18 def title(title) [:title] = title end |