Class: Peacock::CLIHash
- Inherits:
-
Object
- Object
- Peacock::CLIHash
- Defined in:
- lib/peacock/cli_hash.rb
Instance Attribute Summary collapse
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
Instance Method Summary collapse
- #dirs ⇒ Object
- #engine ⇒ Object
- #files ⇒ Object
-
#initialize ⇒ CLIHash
constructor
A new instance of CLIHash.
- #opts ⇒ Object
- #push(type, str) ⇒ Object
- #root_ignore? ⇒ Boolean
- #silent? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ CLIHash
Returns a new instance of CLIHash.
7 8 9 10 11 12 |
# File 'lib/peacock/cli_hash.rb', line 7 def initialize @hash = Hash.new @hash[:opts] = Array.new @hash[:files] = Array.new @hash[:dirs] = Array.new end |
Instance Attribute Details
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
5 6 7 |
# File 'lib/peacock/cli_hash.rb', line 5 def hash @hash end |
Instance Method Details
#dirs ⇒ Object
31 32 33 |
# File 'lib/peacock/cli_hash.rb', line 31 def dirs @hash[:dirs] end |
#engine ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/peacock/cli_hash.rb', line 47 def engine if opts.include?('-e') return Peacock::Engine::Extractor else return Peacock::Engine::Ignorer end end |
#files ⇒ Object
27 28 29 |
# File 'lib/peacock/cli_hash.rb', line 27 def files @hash[:files] end |
#opts ⇒ Object
23 24 25 |
# File 'lib/peacock/cli_hash.rb', line 23 def opts @hash[:opts] end |
#push(type, str) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/peacock/cli_hash.rb', line 14 def push(type, str) if type == :dirs str = str + '/' unless str =~ /\/$/ # add backlash to dir name if it does not exist yet str = '/' + str unless str =~ /^\// # add backlash to beginning of dir name if it does not exist yet end @hash[type].push(str) end |
#root_ignore? ⇒ Boolean
39 40 41 |
# File 'lib/peacock/cli_hash.rb', line 39 def root_ignore? opts.include?('-r') || opts.include?('--root') end |
#silent? ⇒ Boolean
43 44 45 |
# File 'lib/peacock/cli_hash.rb', line 43 def silent? opts.include?('-s') || opts.include?('--silent') end |
#to_s ⇒ Object
35 36 37 |
# File 'lib/peacock/cli_hash.rb', line 35 def to_s hash.to_s end |