Class: Lita::GoogleActivity
- Inherits:
-
Object
- Object
- Lita::GoogleActivity
- Defined in:
- lib/lita/google_activity.rb
Instance Attribute Summary collapse
-
#actor ⇒ Object
readonly
Returns the value of attribute actor.
-
#ip ⇒ Object
readonly
Returns the value of attribute ip.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(time:, actor:, ip:, name:, params:) ⇒ GoogleActivity
constructor
A new instance of GoogleActivity.
- #to_msg ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(time:, actor:, ip:, name:, params:) ⇒ GoogleActivity
Returns a new instance of GoogleActivity.
20 21 22 23 24 25 26 |
# File 'lib/lita/google_activity.rb', line 20 def initialize(time:, actor:, ip:, name:, params:) @time = time @actor = actor @ip = ip @name = name @params = params end |
Instance Attribute Details
#actor ⇒ Object (readonly)
Returns the value of attribute actor.
3 4 5 |
# File 'lib/lita/google_activity.rb', line 3 def actor @actor end |
#ip ⇒ Object (readonly)
Returns the value of attribute ip.
3 4 5 |
# File 'lib/lita/google_activity.rb', line 3 def ip @ip end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/lita/google_activity.rb', line 3 def name @name end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
3 4 5 |
# File 'lib/lita/google_activity.rb', line 3 def params @params end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
3 4 5 |
# File 'lib/lita/google_activity.rb', line 3 def time @time end |
Class Method Details
.from_api(item) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/lita/google_activity.rb', line 5 def self.from_api(item) item.events.map { |event| GoogleActivity.new( time: item.id.time, actor: item.actor.email, ip: item.ip_address, name: event.name, params: event.parameters.inject({}) { |accum, param| accum[param.name] = param.value accum } ) } end |
Instance Method Details
#to_msg ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/lita/google_activity.rb', line 32 def to_msg <<~EOF Date: #{@time.httpdate} Admin User: #{@actor} Action: #{@name.capitalize.gsub('_', ' ')} #{values} EOF end |
#to_s ⇒ Object
28 29 30 |
# File 'lib/lita/google_activity.rb', line 28 def to_s @actor end |