Class: XLIFFer::XLIFF::File
- Inherits:
-
Object
- Object
- XLIFFer::XLIFF::File
- Defined in:
- lib/xliffer/xliff/file.rb
Instance Attribute Summary collapse
-
#original ⇒ Object
(also: #file_name)
readonly
Returns the value of attribute original.
-
#source_language ⇒ Object
Returns the value of attribute source_language.
-
#strings ⇒ Object
readonly
Returns the value of attribute strings.
-
#target_language ⇒ Object
Returns the value of attribute target_language.
Instance Method Summary collapse
- #[](id) ⇒ Object
- #[]=(id, target) ⇒ Object
-
#initialize(xml) ⇒ File
constructor
A new instance of File.
Constructor Details
#initialize(xml) ⇒ File
Returns a new instance of File.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/xliffer/xliff/file.rb', line 9 def initialize(xml) unless XLIFF::xml_element?(xml) and file?(xml) raise ArgumentError, "can't create a File without a file subtree" end @xml = xml @original = @xml.attr("original") @source_language = @xml.attr("source-language") @target_language = @xml.attr("target-language") @strings = @xml.xpath('.//trans-unit').map{|tu| String.new(tu) } end |
Instance Attribute Details
#original ⇒ Object (readonly) Also known as: file_name
Returns the value of attribute original.
7 8 9 |
# File 'lib/xliffer/xliff/file.rb', line 7 def original @original end |
#source_language ⇒ Object
Returns the value of attribute source_language.
7 8 9 |
# File 'lib/xliffer/xliff/file.rb', line 7 def source_language @source_language end |
#strings ⇒ Object (readonly)
Returns the value of attribute strings.
7 8 9 |
# File 'lib/xliffer/xliff/file.rb', line 7 def strings @strings end |
#target_language ⇒ Object
Returns the value of attribute target_language.
7 8 9 |
# File 'lib/xliffer/xliff/file.rb', line 7 def target_language @target_language end |
Instance Method Details
#[](id) ⇒ Object
22 23 24 |
# File 'lib/xliffer/xliff/file.rb', line 22 def [](id) @strings.find { |s| s.id == id } end |
#[]=(id, target) ⇒ Object
26 27 28 |
# File 'lib/xliffer/xliff/file.rb', line 26 def []=(id, target) self[id].target = target end |