Class: Chat::DotCommand::Gif

Inherits:
Object
  • Object
show all
Defined in:
app/models/chat/dot_command/gif.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, text) ⇒ Gif

Returns a new instance of Gif.



8
9
10
11
# File 'app/models/chat/dot_command/gif.rb', line 8

def initialize(message, text)
  @message = message
  @text = text
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



6
7
8
# File 'app/models/chat/dot_command/gif.rb', line 6

def message
  @message
end

#textObject (readonly)

Returns the value of attribute text.



6
7
8
# File 'app/models/chat/dot_command/gif.rb', line 6

def text
  @text
end

Instance Method Details

#performObject



13
14
15
16
# File 'app/models/chat/dot_command/gif.rb', line 13

def perform
  message.image = open(::Giphy.random(text).image_url)
  message.text = nil
end