Class: IspUsage::Fetchers::Fetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/ispusage/fetchers/fetcher.rb

Direct Known Subclasses

AUIinet, AUInternode, AUOptus, AUThree, AUTranslink

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Fetcher

Returns a new instance of Fetcher.



9
10
11
12
13
14
# File 'lib/ispusage/fetchers/fetcher.rb', line 9

def initialize(options)
  @username = options[:username]
  @password = options[:password]
  self.options = options
  self.usage_periods = []
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



7
8
9
# File 'lib/ispusage/fetchers/fetcher.rb', line 7

def options
  @options
end

#passwordObject

Returns the value of attribute password.



7
8
9
# File 'lib/ispusage/fetchers/fetcher.rb', line 7

def password
  @password
end

#usage_periodsObject

Returns the value of attribute usage_periods.



7
8
9
# File 'lib/ispusage/fetchers/fetcher.rb', line 7

def usage_periods
  @usage_periods
end

#usernameObject

Returns the value of attribute username.



7
8
9
# File 'lib/ispusage/fetchers/fetcher.rb', line 7

def username
  @username
end

Instance Method Details

#to_hashObject



16
17
18
19
20
21
22
# File 'lib/ispusage/fetchers/fetcher.rb', line 16

def to_hash
  {
    :isp => self.class.to_s.split('::').last,
    :username => @username,
    :usage_periods => self.usage_periods.map(&:to_hash)
  }
end

#to_jsonObject



24
25
26
# File 'lib/ispusage/fetchers/fetcher.rb', line 24

def to_json
  to_hash.to_json
end