class Cxeed::Credential
Constants
- CREDENTIAL_FILE_PATH
Attributes
company_code[RW]
employee_code[RW]
login_url[RW]
password[RW]
Public Class Methods
new(filename = CREDENTIAL_FILE_PATH)
click to toggle source
# File lib/cxeed/credential.rb, line 11 def initialize(filename = CREDENTIAL_FILE_PATH) if File.exists?(File.expand_path(filename)) json = open(File.expand_path(filename)) {|io| JSON.load(io) } @login_url = json['login_url'] @company_code = json['company_code'] @employee_code = json['employee_code'] @password = json['password'] end end
Public Instance Methods
store()
click to toggle source
# File lib/cxeed/credential.rb, line 27 def store File.open(File.expand_path(CREDENTIAL_FILE_PATH), 'w', 0600) do |file| file.puts self.to_json end end
to_json()
click to toggle source
# File lib/cxeed/credential.rb, line 21 def to_json hash = {} instance_variables.each {|var| hash[var.to_s.delete('@')] = instance_variable_get(var) } hash.to_json end