Class: CampfireExport::Account

Inherits:
Object
  • Object
show all
Includes:
IO, TimeZone
Defined in:
lib/campfire_export.rb

Constant Summary

Constants included from TimeZone

TimeZone::MAPPING

Class Attribute Summary collapse

Instance Method Summary collapse

Methods included from TimeZone

#find_tzinfo

Methods included from IO

#api_url, #export_dir, #export_file, #get, #log, #verify_export, #zero_pad

Constructor Details

#initialize(subdomain, api_token) ⇒ Account

Returns a new instance of Account.



139
140
141
142
143
# File 'lib/campfire_export.rb', line 139

def initialize(subdomain, api_token)
  Account.subdomain = subdomain
  Account.api_token = api_token
  Account.base_url  = "https://#{subdomain}.campfirenow.com"
end

Class Attribute Details

.api_tokenObject

Returns the value of attribute api_token.



136
137
138
# File 'lib/campfire_export.rb', line 136

def api_token
  @api_token
end

.base_urlObject

Returns the value of attribute base_url.



136
137
138
# File 'lib/campfire_export.rb', line 136

def base_url
  @base_url
end

.subdomainObject

Returns the value of attribute subdomain.



136
137
138
# File 'lib/campfire_export.rb', line 136

def subdomain
  @subdomain
end

.timezoneObject

Returns the value of attribute timezone.



136
137
138
# File 'lib/campfire_export.rb', line 136

def timezone
  @timezone
end

Instance Method Details

#find_timezoneObject



145
146
147
148
149
# File 'lib/campfire_export.rb', line 145

def find_timezone
  settings = Nokogiri::XML get('/account.xml').body
  selected_zone = settings.xpath('/account/time-zone')
  Account.timezone = find_tzinfo(selected_zone.text)
end

#roomsObject



151
152
153
154
# File 'lib/campfire_export.rb', line 151

def rooms
  doc = Nokogiri::XML get('/rooms.xml').body
  doc.xpath('/rooms/room').map {|room_xml| Room.new(room_xml) }
end