Module: Quandl::Command::Task::Configurable
- Extended by:
- ActiveSupport::Concern
- Included in:
- Quandl::Command::Task
- Defined in:
- lib/quandl/command/task/configurable.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #ask_for_confirmation!(message = nil) ⇒ Object
- #config ⇒ Object
- #confirmed?(message = nil) ⇒ Boolean
- #declared_params ⇒ Object
- #force_yes? ⇒ Boolean
- #page ⇒ Object
- #trace? ⇒ Boolean
- #verbose? ⇒ Boolean
Instance Method Details
#ask_for_confirmation!(message = nil) ⇒ Object
47 48 49 50 |
# File 'lib/quandl/command/task/configurable.rb', line 47 def ask_for_confirmation!(=nil) = "Are you sure?" if .blank? ['y','yes'].include?( ask("#{} (y/n)") ) end |
#config ⇒ Object
56 57 58 |
# File 'lib/quandl/command/task/configurable.rb', line 56 def config @config ||= Quandl::Command::Config.new( ) end |
#confirmed?(message = nil) ⇒ Boolean
38 39 40 41 |
# File 'lib/quandl/command/task/configurable.rb', line 38 def confirmed?(=nil) return true if force_yes? ask_for_confirmation!() end |
#declared_params ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/quandl/command/task/configurable.rb', line 16 def declared_params params = {} self.class..each do |class_type, opts| opts.each do |name, desc| if .is_a?(OpenStruct) params[name] = self..send(name) else params[name] = self.[name] if self.[name].present? end end end params end |
#force_yes? ⇒ Boolean
43 44 45 |
# File 'lib/quandl/command/task/configurable.rb', line 43 def force_yes? .force_yes == true end |
#page ⇒ Object
52 53 54 |
# File 'lib/quandl/command/task/configurable.rb', line 52 def page @page ||= .page.to_i || 1 end |
#trace? ⇒ Boolean
34 35 36 |
# File 'lib/quandl/command/task/configurable.rb', line 34 def trace? .trace == true end |
#verbose? ⇒ Boolean
30 31 32 |
# File 'lib/quandl/command/task/configurable.rb', line 30 def verbose? .verbose == true end |