Class: Tc211::Termbase::TermWorkbook
- Inherits:
-
Object
- Object
- Tc211::Termbase::TermWorkbook
- Defined in:
- lib/tc211/termbase/term_workbook.rb
Constant Summary collapse
- SPECIAL_SHEETS =
[ "Glossary Information", "Character Encoding Spreadsheet", ].freeze
Instance Attribute Summary collapse
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#glossary_info ⇒ Object
Returns the value of attribute glossary_info.
-
#languages ⇒ Object
Returns the value of attribute languages.
-
#workbook ⇒ Object
Returns the value of attribute workbook.
Instance Method Summary collapse
- #find_sheet_by_name(sheet_name) ⇒ Object
-
#initialize(filepath) ⇒ TermWorkbook
constructor
A new instance of TermWorkbook.
- #language_sheet(lang) ⇒ Object
- #languages_supported ⇒ Object
- #write_glossary_info ⇒ Object
Constructor Details
#initialize(filepath) ⇒ TermWorkbook
Returns a new instance of TermWorkbook.
17 18 19 20 21 22 23 24 25 |
# File 'lib/tc211/termbase/term_workbook.rb', line 17 def initialize(filepath) @filename = filepath @workbook = Creek::Book.new(filepath) @glossary_info = InformationSheet.new( find_sheet_by_name("Glossary Information"), ) @languages = languages_supported self end |
Instance Attribute Details
#filename ⇒ Object
Returns the value of attribute filename.
10 11 12 |
# File 'lib/tc211/termbase/term_workbook.rb', line 10 def filename @filename end |
#glossary_info ⇒ Object
Returns the value of attribute glossary_info.
10 11 12 |
# File 'lib/tc211/termbase/term_workbook.rb', line 10 def glossary_info @glossary_info end |
#languages ⇒ Object
Returns the value of attribute languages.
10 11 12 |
# File 'lib/tc211/termbase/term_workbook.rb', line 10 def languages @languages end |
#workbook ⇒ Object
Returns the value of attribute workbook.
10 11 12 |
# File 'lib/tc211/termbase/term_workbook.rb', line 10 def workbook @workbook end |
Instance Method Details
#find_sheet_by_name(sheet_name) ⇒ Object
39 40 41 42 43 |
# File 'lib/tc211/termbase/term_workbook.rb', line 39 def find_sheet_by_name(sheet_name) @workbook.sheets.detect do |sheet| sheet.name == sheet_name end end |
#language_sheet(lang) ⇒ Object
33 34 35 36 37 |
# File 'lib/tc211/termbase/term_workbook.rb', line 33 def language_sheet(lang) raise unless @languages.include?(lang) TerminologySheet.new(find_sheet_by_name(lang)) end |
#languages_supported ⇒ Object
27 28 29 30 31 |
# File 'lib/tc211/termbase/term_workbook.rb', line 27 def languages_supported @workbook.sheets.map(&:name).reject! do |name| SPECIAL_SHEETS.include?(name) end end |
#write_glossary_info ⇒ Object
45 46 47 48 49 50 |
# File 'lib/tc211/termbase/term_workbook.rb', line 45 def write_glossary_info glossary_info_fn = Pathname.new(@filename).sub_ext(".yaml") File.open(glossary_info_fn, "w") do |file| file.write(glossary_info.to_yaml) end end |