Class: Cript::HidrCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/cript/hidr_command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ HidrCommand

Returns a new instance of HidrCommand.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/cript/hidr_command.rb', line 9

def initialize(argv)
  @argv = argv.dup

  @options = {
    mode:    nil,
    infile:  '-',
    outfile: '-',
    force:   false,
    b0:      '0',
    b1:      '1',
    debug:   false
  }

  parse!
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/cript/hidr_command.rb', line 7

def options
  @options
end

Instance Method Details

#run!Object



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/cript/hidr_command.rb', line 25

def run!
  validate_mode
  hidr = build_hidr
  data = read_data
  get_writer do |writer|
    if @options[:mode] == 'hide'
      writer.print hidr.hide(data)
    else
      writer.print hidr.show(data)
    end
  end
end