Class: NeocitiesRed::Services::Site::Informer
- Inherits:
-
Object
- Object
- NeocitiesRed::Services::Site::Informer
- Defined in:
- lib/neocities_red/services/site/informer.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
-
#initialize(client, subargs = [], sitename = nil) ⇒ Informer
constructor
A new instance of Informer.
- #pretty_print ⇒ Object
- #stats ⇒ Object
Constructor Details
#initialize(client, subargs = [], sitename = nil) ⇒ Informer
Returns a new instance of Informer.
14 15 16 17 18 19 |
# File 'lib/neocities_red/services/site/informer.rb', line 14 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.
12 13 14 |
# File 'lib/neocities_red/services/site/informer.rb', line 12 def client @client end |
Instance Method Details
#pretty_print ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/neocities_red/services/site/informer.rb', line 29 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
21 22 23 24 25 26 27 |
# File 'lib/neocities_red/services/site/informer.rb', line 21 def stats response = @client.info(@subargs[0] || @sitename) raise NeocitiesRed::Services::ClientError, response if response[:result] == "error" response end |