Class: TTT::Binary

Inherits:
Object
  • Object
show all
Defined in:
lib/ttt/binary.rb

Overview

The code for ttt/bin

Defined Under Namespace

Classes: Parser

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv, io = {}) ⇒ Binary

Returns a new instance of Binary.



12
13
14
15
16
17
# File 'lib/ttt/binary.rb', line 12

def initialize(argv, io={})
  self.fileout = io.fetch :fileout, $stdout
  self.fileerr = io.fetch :fileerr, $stderr
  self.filein  = io.fetch :filein,  $stdin
  parse argv
end

Instance Attribute Details

#fileerrObject

Returns the value of attribute fileerr.



10
11
12
# File 'lib/ttt/binary.rb', line 10

def fileerr
  @fileerr
end

#fileinObject

Returns the value of attribute filein.



10
11
12
# File 'lib/ttt/binary.rb', line 10

def filein
  @filein
end

#fileoutObject

Returns the value of attribute fileout.



10
11
12
# File 'lib/ttt/binary.rb', line 10

def fileout
  @fileout
end

Instance Method Details

#has_interface?(interface_name) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/ttt/binary.rb', line 27

def has_interface?(interface_name)
  TTT::Interface.registered? interface_name
end

#interface(interface_name) ⇒ Object



35
36
37
# File 'lib/ttt/binary.rb', line 35

def interface(interface_name)
  TTT::Interface.registered[interface_name]
end

#list_of_registeredObject



31
32
33
# File 'lib/ttt/binary.rb', line 31

def list_of_registered
  TTT::Interface.registered_names.map(&:inspect).join(', ')
end

#parse(argv) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/ttt/binary.rb', line 19

def parse(argv)
  argv = ['-h'] if argv.empty?
  Parser.new(self).parse argv
rescue OptionParser::MissingArgument => e
  fileerr.puts e.message
  Kernel.exit 1
end