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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a85b08f24e3c10c52139bcf60807f9c7a9237bbe
4
- data.tar.gz: ee0bb3a257e264779db0043c92695171d3b82b97
3
+ metadata.gz: 57669f8e6ac32c726591c41f4d532e9b3fbf29f3
4
+ data.tar.gz: 686035f10112a09ce7bd172b5e901a0548cefe41
5
5
  SHA512:
6
- metadata.gz: aca84312dc34a28c6e48eb5865265309e308209a56bb4b47145de1e47f02fd985d3e2b3107f403ef37c39a2fabbfd3158f49f563bc0b707b2ab9a0989f672f99
7
- data.tar.gz: 92f892bb510b3f6fde04de10abe420ae49ad196a7c7b5c9c383cab5478e40d87466ec32be5ce810ce54ac86ad159d5174d26be2ebb914f43b1fe5c57f093172a
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
- require 'open_weather'
4
- require 'stock_quote'
3
+ require_relative "../lib/smart_alec"
4
+
5
5
 
6
6
  command = ARGV[0]
7
7
  option = ARGV[1]
8
8
 
9
- if command == "time"
10
- puts "The date and time currently is: " + Time.now.strftime("%A, %B %d %Y %l:%M %p")
11
- elsif command == "weather"
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
- # Your code goes here...
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
@@ -0,0 +1,7 @@
1
+ module SmartAlec
2
+ class FriendlyTime
3
+ def get
4
+ Time.now.strftime("%A, %B %d %Y %l:%M %p")
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,13 @@
1
+ require 'stock_quote'
2
+
3
+ module SmartAlec
4
+ class Stock
5
+ def initialize(symbol)
6
+ @stock_data = StockQuote::Stock.quote(symbol)
7
+ end
8
+
9
+ def current_price
10
+ @stock_data.bid_realtime
11
+ end
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module SmartAlec
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -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.1
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-07-31 00:00:00.000000000 Z
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: