class Drumknott::CLI
Constants
- EMPTY_CACHE
- HELP_MESSAGE
Attributes
arguments[R]
command[R]
Public Class Methods
call( command, arguments = [], name = nil, key = nil, include_pages = nil )
click to toggle source
# File lib/drumknott/cli.rb, line 22 def self.call( command, arguments = [], name = nil, key = nil, include_pages = nil ) new(command, arguments, name, key, include_pages).call end
new( command, arguments = [], name = nil, key = nil, include_pages = nil )
click to toggle source
# File lib/drumknott/cli.rb, line 28 def initialize( command, arguments = [], name = nil, key = nil, include_pages = nil ) @command = command @arguments = arguments @name = name @key = key @include_pages = include_pages end
Public Instance Methods
call()
click to toggle source
# File lib/drumknott/cli.rb, line 38 def call case command when "refresh" Drumknott::Refresh.call name, key, include_pages? when "keys" Drumknott::Keys.call arguments else puts "Unknown command #{command}." unless command == "help" puts HELP_MESSAGE end end
Private Instance Methods
cache()
click to toggle source
# File lib/drumknott/cli.rb, line 54 def cache return EMPTY_CACHE unless File.exist? ".drumknott" @cache ||= JSON.parse File.read(".drumknott") end
include_pages?()
click to toggle source
# File lib/drumknott/cli.rb, line 68 def include_pages? return @include_pages unless @include_pages.nil? return cache["pages"] unless cache["pages"].nil? Drumknott::IncludePages.call ENV["DRUMKNOTT_PAGES"] end
key()
click to toggle source
# File lib/drumknott/cli.rb, line 64 def key @key || cache["key"] || ENV["DRUMKNOTT_KEY"] end
name()
click to toggle source
# File lib/drumknott/cli.rb, line 60 def name @name || cache["name"] || ENV["DRUMKNOTT_NAME"] end