Class: NeocitiesRed::Services::ProfileInfo
- Inherits:
-
Object
- Object
- NeocitiesRed::Services::ProfileInfo
- Defined in:
- lib/neocities_red/services/profile_info.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
-
#initialize(client, subargs = [], sitename = nil) ⇒ ProfileInfo
constructor
A new instance of ProfileInfo.
- #pretty_print ⇒ Object
- #stats ⇒ Object
Constructor Details
#initialize(client, subargs = [], sitename = nil) ⇒ ProfileInfo
Returns a new instance of ProfileInfo.
13 14 15 16 17 18 |
# File 'lib/neocities_red/services/profile_info.rb', line 13 def initialize(client, = [], sitename = nil) @client = client @subargs = @sitename = sitename @pastel = Pastel.new(eachline: "\n") end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
11 12 13 |
# File 'lib/neocities_red/services/profile_info.rb', line 11 def client @client end |
Instance Method Details
#pretty_print ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/neocities_red/services/profile_info.rb', line 28 def pretty_print out = [] stats[:info].each do |k, v| v = Time.parse(v).localtime if v && %i[created_at last_updated].include?(k) out << [@pastel.bold(k.to_s), v] end out end |
#stats ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/neocities_red/services/profile_info.rb', line 20 def stats response = @client.info(@subargs[0] || @sitename) raise NeocitiesRed::Services::ClientError, response if response[:result] == "error" response end |