smart_alec 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/alec +5 -14
- data/lib/smart_alec.rb +18 -1
- data/lib/smart_alec/friendly_time.rb +7 -0
- data/lib/smart_alec/stock.rb +13 -0
- data/lib/smart_alec/version.rb +1 -1
- data/lib/smart_alec/weather.rb +17 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57669f8e6ac32c726591c41f4d532e9b3fbf29f3
|
4
|
+
data.tar.gz: 686035f10112a09ce7bd172b5e901a0548cefe41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0966376dabe3036d5c2eaaf160d5924e33ac9a8f534e83d18965e5d49858c35703b9c8781155067d35310e1f3d5d1fd5c813c5fce541dc32c4f310da0725bfb3
|
7
|
+
data.tar.gz: 56340ce9f872bd649a574e8f159c9ee0911451f3bdb3cebccb3b654bf720ad8fd948232fbfb7198853d5fc4a88ed78b191e908fe2493bfd937c8d2540f99c73a
|
data/bin/alec
CHANGED
@@ -1,20 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
require_relative "../lib/smart_alec"
|
4
|
+
|
5
5
|
|
6
6
|
command = ARGV[0]
|
7
7
|
option = ARGV[1]
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
weather_info = OpenWeather::Current.city(option)
|
13
|
-
temp = ((weather_info["main"]["temp"].to_f - 273.15) * 1.8 + 32).round(2)
|
14
|
-
puts "The current temperature in #{option} is #{temp}."
|
15
|
-
elsif command == "stock"
|
16
|
-
bid = StockQuote::Stock.quote(option).bid_realtime
|
17
|
-
puts "The realtime bid for #{option.upcase} is $#{bid}."
|
18
|
-
else
|
19
|
-
puts "Alec doesn't understand that command."
|
20
|
-
end
|
9
|
+
robot = SmartAlec::Robot.new
|
10
|
+
robot.do_task(command, option)
|
11
|
+
|
data/lib/smart_alec.rb
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
require "smart_alec/version"
|
2
|
+
require "smart_alec/friendly_time"
|
3
|
+
require "smart_alec/weather"
|
4
|
+
require "smart_alec/stock"
|
2
5
|
|
3
6
|
module SmartAlec
|
4
|
-
|
7
|
+
class Robot
|
8
|
+
def do_task(command, option=nil)
|
9
|
+
if command == "time"
|
10
|
+
puts "The date and time currently is: " + SmartAlec::CurrentTime.new.get
|
11
|
+
elsif command == "weather"
|
12
|
+
weather = SmartAlec::Weather.new(option)
|
13
|
+
puts "The current temperature in #{option.capitalize} is #{weather.fahrenheit} degrees fahrenheit."
|
14
|
+
elsif command == "stock"
|
15
|
+
stock = SmartAlec::Stock.new(option)
|
16
|
+
puts "The realtime bid for #{option.upcase} is $#{stock.current_price}."
|
17
|
+
else
|
18
|
+
puts "Alec doesn't understand that command."
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
5
22
|
end
|
data/lib/smart_alec/version.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'open_weather'
|
2
|
+
|
3
|
+
module SmartAlec
|
4
|
+
class Weather
|
5
|
+
def initialize(location)
|
6
|
+
@weather_info = OpenWeather::Current.city(location)
|
7
|
+
end
|
8
|
+
|
9
|
+
def kelvin
|
10
|
+
@weather_info["main"]["temp"]
|
11
|
+
end
|
12
|
+
|
13
|
+
def fahrenheit
|
14
|
+
((kelvin.to_f - 273.15) * 1.8 + 32).round(2)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_alec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jay Wengrow
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -82,7 +82,10 @@ files:
|
|
82
82
|
- Rakefile
|
83
83
|
- bin/alec
|
84
84
|
- lib/smart_alec.rb
|
85
|
+
- lib/smart_alec/friendly_time.rb
|
86
|
+
- lib/smart_alec/stock.rb
|
85
87
|
- lib/smart_alec/version.rb
|
88
|
+
- lib/smart_alec/weather.rb
|
86
89
|
- smart_alec.gemspec
|
87
90
|
homepage: ''
|
88
91
|
licenses:
|