Module: Juhe::Express
- Defined in:
- lib/juhe_ruby/express.rb
Class Attribute Summary collapse
-
.companies ⇒ Object
Returns the value of attribute companies.
Class Method Summary collapse
- .company_code_of(company_name, options = nil) ⇒ Object
- .refresh_companies(options) ⇒ Object
- .search(company_name, number, options = nil) ⇒ Object
Class Attribute Details
.companies ⇒ Object
Returns the value of attribute companies.
8 9 10 |
# File 'lib/juhe_ruby/express.rb', line 8 def companies @companies end |
Class Method Details
.company_code_of(company_name, options = nil) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/juhe_ruby/express.rb', line 25 def self.company_code_of(company_name, = nil) refresh_companies() if @companies.nil? @companies.each do |company| return company["no"] if company["com"] == company_name end end |
.refresh_companies(options) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/juhe_ruby/express.rb', line 34 def self.refresh_companies() app_key = ([:app_key] if ) || Juhe::Express.app_key result = JSON.parse(open(BASE_URL+"/com?key="+app_key).read) raise result["reason"] if result["resultcode"] != "200" @companies = result["result"] end |
.search(company_name, number, options = nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/juhe_ruby/express.rb', line 12 def self.search(company_name, number, = nil) app_key = ([:app_key] if ) || Juhe::Express.app_key url = BASE_URL \ + "/index?key=" + app_key \ + "&no=" + number \ + "&com=" + company_code_of(company_name, ) result = JSON.parse(open(url).read) raise result["reason"] if result["resultcode"] != "200" result["result"] end |