Module: Quandl::Command::Task::Commandable::ClassMethods
- Defined in:
- lib/quandl/command/task/commandable.rb
Instance Method Summary collapse
- #call(args = [], options = {}) ⇒ Object
- #command_name(value = nil) ⇒ Object
- #configure(app) ⇒ Object
- #description(value = nil) ⇒ Object
- #disable! ⇒ Object
- #disabled? ⇒ Boolean
- #inherited(klass) ⇒ Object
- #options(value = nil) ⇒ Object
- #syntax(value = nil) ⇒ Object
Instance Method Details
#call(args = [], options = {}) ⇒ Object
58 59 60 61 62 |
# File 'lib/quandl/command/task/commandable.rb', line 58 def call(args=[], ={}) args = Array(args) = () self.new( args, ).call end |
#command_name(value = nil) ⇒ Object
43 44 45 46 |
# File 'lib/quandl/command/task/commandable.rb', line 43 def command_name(value=nil) @command_name = value if value.present? @command_name ||= name.to_s.split("::").last.downcase end |
#configure(app) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/quandl/command/task/commandable.rb', line 20 def configure(app) return if disabled? app.command(command_name) do |c| c.syntax = syntax c.description = description c.action{|a,o| call(a,o) } (c) end end |
#description(value = nil) ⇒ Object
48 49 50 51 |
# File 'lib/quandl/command/task/commandable.rb', line 48 def description(value=nil) @description = value if value.present? @description ||= "No description." end |
#disable! ⇒ Object
34 35 36 |
# File 'lib/quandl/command/task/commandable.rb', line 34 def disable! @disabled = true end |
#disabled? ⇒ Boolean
30 31 32 |
# File 'lib/quandl/command/task/commandable.rb', line 30 def disabled? @disabled == true end |
#inherited(klass) ⇒ Object
15 16 17 18 |
# File 'lib/quandl/command/task/commandable.rb', line 15 def inherited(klass) Quandl::Command::Tasks.tasks << klass unless Quandl::Command::Tasks.tasks.include?(klass) klass.(@options) end |
#options(value = nil) ⇒ Object
53 54 55 56 |
# File 'lib/quandl/command/task/commandable.rb', line 53 def (value=nil) @options = value if value.present? @options ||= {} end |
#syntax(value = nil) ⇒ Object
38 39 40 41 |
# File 'lib/quandl/command/task/commandable.rb', line 38 def syntax(value=nil) @syntax = value if value.present? @syntax ||= "quandl #{command_name}" end |