Class: Twb::Workbook
- Inherits:
-
Object
- Object
- Twb::Workbook
- Defined in:
- lib/twb/workbook.rb
Instance Attribute Summary collapse
-
#build ⇒ Object
readonly
Returns the value of attribute build.
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
-
#modtime ⇒ Object
readonly
Returns the value of attribute modtime.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#ndoc ⇒ Object
readonly
Returns the value of attribute ndoc.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #dataSourceNodes ⇒ Object
- #dataSources ⇒ Object
-
#initialize(twbWithDir) ⇒ Workbook
constructor
A new instance of Workbook.
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.(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
#build ⇒ Object (readonly)
Returns the value of attribute build.
22 23 24 |
# File 'lib/twb/workbook.rb', line 22 def build @build end |
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
22 23 24 |
# File 'lib/twb/workbook.rb', line 22 def dir @dir end |
#modtime ⇒ Object (readonly)
Returns the value of attribute modtime.
22 23 24 |
# File 'lib/twb/workbook.rb', line 22 def modtime @modtime end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
22 23 24 |
# File 'lib/twb/workbook.rb', line 22 def name @name end |
#ndoc ⇒ Object (readonly)
Returns the value of attribute ndoc.
22 23 24 |
# File 'lib/twb/workbook.rb', line 22 def ndoc @ndoc end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
22 23 24 |
# File 'lib/twb/workbook.rb', line 22 def version @version end |
Instance Method Details
#dataSourceNodes ⇒ Object
35 36 37 |
# File 'lib/twb/workbook.rb', line 35 def dataSourceNodes @ndoc.xpath('//workbook/datasources/datasource').to_a end |
#dataSources ⇒ Object
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 |