Class: PhraseApp::Android::PhraseAppClient
- Inherits:
-
Object
- Object
- PhraseApp::Android::PhraseAppClient
- Defined in:
- lib/phraseapp_android/phrase_app_client.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#locale_files ⇒ Object
Returns the value of attribute locale_files.
-
#locales ⇒ Object
Returns the value of attribute locales.
-
#project_id ⇒ Object
Returns the value of attribute project_id.
-
#sub_path ⇒ Object
Returns the value of attribute sub_path.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ PhraseAppClient
constructor
A new instance of PhraseAppClient.
- #locale_file_name(file_name, locale) ⇒ Object
- #read_locale_file(file_name, locale) ⇒ Object
- #read_xml_file(file_name) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ PhraseAppClient
Returns a new instance of PhraseAppClient.
13 14 15 16 17 18 19 |
# File 'lib/phraseapp_android/phrase_app_client.rb', line 13 def initialize( = {}) credentials = PhraseApp::Auth::Credentials.new token: ([:token] || ENV['PHRASE_ACCESS_TOKEN']) self.client = PhraseApp::Client.new credentials self.project_id = [:project_id] || ENV['PHRASE_PROJECT_ID'] self.sub_path = [:path] find_locales end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
11 12 13 |
# File 'lib/phraseapp_android/phrase_app_client.rb', line 11 def client @client end |
#locale_files ⇒ Object
Returns the value of attribute locale_files.
11 12 13 |
# File 'lib/phraseapp_android/phrase_app_client.rb', line 11 def locale_files @locale_files end |
#locales ⇒ Object
Returns the value of attribute locales.
11 12 13 |
# File 'lib/phraseapp_android/phrase_app_client.rb', line 11 def locales @locales end |
#project_id ⇒ Object
Returns the value of attribute project_id.
11 12 13 |
# File 'lib/phraseapp_android/phrase_app_client.rb', line 11 def project_id @project_id end |
#sub_path ⇒ Object
Returns the value of attribute sub_path.
11 12 13 |
# File 'lib/phraseapp_android/phrase_app_client.rb', line 11 def sub_path @sub_path end |
Instance Method Details
#locale_file_name(file_name, locale) ⇒ Object
34 35 36 37 |
# File 'lib/phraseapp_android/phrase_app_client.rb', line 34 def locale_file_name(file_name, locale) locale = '-' + locale unless locale.nil? locale_files.find { |f| f.end_with?("values#{locale}/#{file_name}.xml") } end |
#read_locale_file(file_name, locale) ⇒ Object
30 31 32 |
# File 'lib/phraseapp_android/phrase_app_client.rb', line 30 def read_locale_file(file_name, locale) read_xml_file locale_file_name(file_name, locale) end |
#read_xml_file(file_name) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/phraseapp_android/phrase_app_client.rb', line 21 def read_xml_file(file_name) if file_name f = File.open file_name doc = Nokogiri::XML f f.close doc end end |