Class: Peacock::CLIHash

Inherits:
Object
  • Object
show all
Defined in:
lib/peacock/cli_hash.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCLIHash

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

#hashObject (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

#dirsObject



31
32
33
# File 'lib/peacock/cli_hash.rb', line 31

def dirs
  @hash[:dirs]
end

#engineObject



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

#filesObject



27
28
29
# File 'lib/peacock/cli_hash.rb', line 27

def files
  @hash[:files]
end

#optsObject



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

Returns:

  • (Boolean)


39
40
41
# File 'lib/peacock/cli_hash.rb', line 39

def root_ignore?
  opts.include?('-r') || opts.include?('--root')
end

#silent?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/peacock/cli_hash.rb', line 43

def silent?
  opts.include?('-s') || opts.include?('--silent')
end

#to_sObject



35
36
37
# File 'lib/peacock/cli_hash.rb', line 35

def to_s
  hash.to_s
end