class Ruboty::GrowthForecast::Actions::Show
Attributes
message[R]
Public Class Methods
new(message)
click to toggle source
# File lib/ruboty/growthforecast/actions/show.rb, line 9 def initialize(message) @message = message end
Public Instance Methods
call()
click to toggle source
# File lib/ruboty/growthforecast/actions/show.rb, line 13 def call number = client.by_name(*path).number message.reply reply_message(binding) rescue => e message.reply e.message end
Private Instance Methods
client()
click to toggle source
# File lib/ruboty/growthforecast/actions/show.rb, line 34 def client @client ||= ::GrowthForecast.new(host, port).tap do |client| if username client.username = username client.password = password end end end
format()
click to toggle source
# File lib/ruboty/growthforecast/actions/show.rb, line 22 def format message[:format] || '<%= number %>' end
host()
click to toggle source
# File lib/ruboty/growthforecast/actions/show.rb, line 43 def host ENV['GROWTHFORECAST_HOST'] end
password()
click to toggle source
# File lib/ruboty/growthforecast/actions/show.rb, line 55 def password ENV['GROWTHFORECAST_PASSWORD'] end
path()
click to toggle source
# File lib/ruboty/growthforecast/actions/show.rb, line 30 def path message[:path].split '/' end
port()
click to toggle source
# File lib/ruboty/growthforecast/actions/show.rb, line 47 def port (ENV['GROWTHFORECAST_PORT'] || 80).to_i end
reply_message(b = binding)
click to toggle source
# File lib/ruboty/growthforecast/actions/show.rb, line 26 def reply_message(b = binding) ERB.new(format).result(b) end
username()
click to toggle source
# File lib/ruboty/growthforecast/actions/show.rb, line 51 def username ENV['GROWTHFORECAST_USERNAME'] end