Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

41 lines (32 sloc) 0.739 kb
require 'rubygems'
require 'yahoofinance'
# If using the gem, replace with:
#
# require 'rubygems'
# require 'james'
require File.expand_path '../../lib/james', __FILE__
# Stocks dialog by Florian Hanke.
#
# This is a very simple James example.
#
class StocksDialog
include James::Dialog
attr_reader :quotes, :stocks
def initialize *stocks
@quotes = YahooFinance::ExtendedQuote.new
@stocks = stocks
end
hear 'How are my stocks?' => :stocks
state :stocks do
hear 'Again'
into do
say = []
stocks.each do |stock|
result = quotes.load_quote stock
say << "#{stock} has moved #{result[28]}."
end
say.join ' '
end
end
end
James.use StocksDialog.new('AAPL', 'IBM')
Jump to Line
Something went wrong with that request. Please try again.