Class: Bruno::I18nFile
- Inherits:
-
Object
- Object
- Bruno::I18nFile
- Defined in:
- lib/bruno/i18n_file.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#strings ⇒ Object
writeonly
Sets the attribute strings.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(strings) ⇒ I18nFile
constructor
A new instance of I18nFile.
Constructor Details
#initialize(strings) ⇒ I18nFile
Returns a new instance of I18nFile.
5 6 7 |
# File 'lib/bruno/i18n_file.rb', line 5 def initialize(strings) @strings = strings end |
Instance Attribute Details
#strings=(value) ⇒ Object (writeonly)
Sets the attribute strings
3 4 5 |
# File 'lib/bruno/i18n_file.rb', line 3 def strings=(value) @strings = value end |
Class Method Details
.is_android?(content) ⇒ Boolean
25 26 27 |
# File 'lib/bruno/i18n_file.rb', line 25 def self.is_android?(content) !(content =~ /<string name=".*">.*<\/string>/).nil? end |
.is_ios?(content) ⇒ Boolean
29 30 31 |
# File 'lib/bruno/i18n_file.rb', line 29 def self.is_ios?(content) !(content =~ /".*" = ".*";/).nil? end |
.read(path) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/bruno/i18n_file.rb', line 9 def self.read(path) if !File.readable?(path) raise 'File is not readable' end content = File.read(path) if is_ios?(content) AndroidFile.new(IOSFile.read(content)) elsif is_android?(content) IOSFile.new(AndroidFile.read(content)) else raise 'Format of the file is not correct' end end |