Class: Twb::Workbook

Inherits:
Object
  • Object
show all
Defined in:
lib/twb/workbook.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(twbWithDir) ⇒ Workbook

Returns a new instance of Workbook.



24
25
26
27
28
29
30
31
32
33
# File 'lib/twb/workbook.rb', line 24

def initialize twbWithDir
  file     = File.new(twbWithDir)
  @name    = File.basename(twbWithDir)
  @dir     = File.dirname(File.expand_path(twbWithDir))
  @modtime = File.new(twbWithDir).mtime
  @ndoc = Nokogiri::XML(open(twbWithDir))
  @version = @ndoc.xpath('/workbook/@version')
  @build   = @ndoc.xpath('/workbook/comment()').text.gsub(/^[^0-9]+/,'').strip
  return self
end

Instance Attribute Details

#buildObject (readonly)

Returns the value of attribute build.



22
23
24
# File 'lib/twb/workbook.rb', line 22

def build
  @build
end

#dirObject (readonly)

Returns the value of attribute dir.



22
23
24
# File 'lib/twb/workbook.rb', line 22

def dir
  @dir
end

#modtimeObject (readonly)

Returns the value of attribute modtime.



22
23
24
# File 'lib/twb/workbook.rb', line 22

def modtime
  @modtime
end

#nameObject (readonly)

Returns the value of attribute name.



22
23
24
# File 'lib/twb/workbook.rb', line 22

def name
  @name
end

#ndocObject (readonly)

Returns the value of attribute ndoc.



22
23
24
# File 'lib/twb/workbook.rb', line 22

def ndoc
  @ndoc
end

#versionObject (readonly)

Returns the value of attribute version.



22
23
24
# File 'lib/twb/workbook.rb', line 22

def version
  @version
end

Instance Method Details

#dataSourceNodesObject



35
36
37
# File 'lib/twb/workbook.rb', line 35

def dataSourceNodes
  @ndoc.xpath('//workbook/datasources/datasource').to_a
end

#dataSourcesObject



39
40
41
42
43
44
45
# File 'lib/twb/workbook.rb', line 39

def dataSources
  sources = []
  dataSourceNodes.each do |dsn|
    sources.push Twb::DataSource.new(dsn)
  end
  return sources
end