Class: ViewWorkBook

Inherits:
Object
  • Object
show all
Includes:
BasicLogging
Defined in:
lib/viewworkbook.rb

Constant Summary

Constants included from BasicLogging

BasicLogging::DEBUG, BasicLogging::ERROR, BasicLogging::FATAL, BasicLogging::INFO, BasicLogging::Levels, BasicLogging::UNKNOWN, BasicLogging::WARN

Instance Attribute Summary collapse

Attributes included from BasicLogging

#log_level, #target

Instance Method Summary collapse

Methods included from BasicLogging

is_muted?, #log, mute, set_level, #set_level, set_target, #set_target

Constructor Details

#initialize(*args) ⇒ ViewWorkBook

Returns a new instance of ViewWorkBook.



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

def initialize(*args)
  debug('args is ' << args.to_s)
  wb = args[0]
  path = File.path(wb) if wb
  debug('workbook file will be ' << (path ? path : 'N I L'))

  if(wb)
    msg = ''

    [:exist?, :file?, :readable?].each do |cond| 
      if ! File.send(cond, path)
        msg = "\n\t not " << cond.to_s.split('?')[0]
      end
    end
    if(msg.empty?)
      begin
        @workbook = SheetData.workbook(path)
        view_sheet if @workbook
      end
    else
      error(yellow("Cannot open " << path << ": " << msg))
      # raise IOError.new(msg)
      puts red("\n\tPlease name a valid spreadsheet file! Aborting.")
      puts
      exit false
    end
  end
  debug('initialized')
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



59
60
61
# File 'lib/viewworkbook.rb', line 59

def method_missing(method, *args)
  @workbook.send(method.to_sym, *args)
end

Instance Attribute Details

#workbookObject (readonly)

Returns the value of attribute workbook.



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

def workbook
  @workbook
end

Instance Method Details

#sheet(number) ⇒ Object



63
64
65
# File 'lib/viewworkbook.rb', line 63

def sheet(number)
  view_sheet(number)
end