Class: Termplot::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/termplot/options.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOptions

Returns a new instance of Options.



18
19
20
21
22
23
24
25
26
27
# File 'lib/termplot/options.rb', line 18

def initialize
  @rows       = 19
  @cols       = 80
  @title      = "Series"
  @line_style = "line"
  @color      = "red"
  @debug      = false
  @command    = nil
  @interval   = 1000
end

Instance Attribute Details

#colorObject (readonly)

Returns the value of attribute color.



9
10
11
# File 'lib/termplot/options.rb', line 9

def color
  @color
end

#colsObject (readonly)

Returns the value of attribute cols.



9
10
11
# File 'lib/termplot/options.rb', line 9

def cols
  @cols
end

#commandObject (readonly)

Returns the value of attribute command.



9
10
11
# File 'lib/termplot/options.rb', line 9

def command
  @command
end

#debugObject (readonly)

Returns the value of attribute debug.



9
10
11
# File 'lib/termplot/options.rb', line 9

def debug
  @debug
end

#intervalObject (readonly)

Returns the value of attribute interval.



9
10
11
# File 'lib/termplot/options.rb', line 9

def interval
  @interval
end

#line_styleObject (readonly)

Returns the value of attribute line_style.



9
10
11
# File 'lib/termplot/options.rb', line 9

def line_style
  @line_style
end

#rowsObject (readonly)

Returns the value of attribute rows.



9
10
11
# File 'lib/termplot/options.rb', line 9

def rows
  @rows
end

#titleObject (readonly)

Returns the value of attribute title.



9
10
11
# File 'lib/termplot/options.rb', line 9

def title
  @title
end

Instance Method Details

#modeObject



29
30
31
# File 'lib/termplot/options.rb', line 29

def mode
  @command.nil? ? :stdin : :command
end

#parse_options!Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/termplot/options.rb', line 33

def parse_options!
  # Debug option is parsed manually to prevent it from showing up in the
  # options help
  parse_debug

  OptionParser.new do |opts|
    opts.banner = "Usage: termplot [OPTIONS]"

    parse_rows(opts)
    parse_cols(opts)
    parse_title(opts)
    parse_line_style(opts)
    parse_color(opts)
    parse_command(opts)
    parse_interval(opts)

    opts.on("-h", "--help", "Display this help message") do
      puts opts
      exit(0)
    end

  end.parse!
  self
end