tokusub 0.0.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1acffdcd35bdc8aba7bdfa792a6c57750bad2a81
4
- data.tar.gz: 4f2cb6770aa3db0a0ac8807c6a4139b654c23542
3
+ metadata.gz: bf11adbbf0c38aa3cf0fd1f42981cd1d6c6a1cea
4
+ data.tar.gz: 214b021556b6bafa11c0412da1158a4c9bb84f49
5
5
  SHA512:
6
- metadata.gz: ab1df0a8e749621d87663f81d5d32f7de918eb14fadf172e90ac83c4b32c7c1bec0603306477a581abecc470dc70d6619f66b841cb80a8e9b951168cdafa681e
7
- data.tar.gz: 4bcf5b4ccbe2a9607f2844b0fad0093a33bbb05e50d4d0f454e49ac01a6b5730c0112e6e72799412ed293abedc2f025c9b0dbfa6f1c552cd5605d2cf4185b12c
6
+ metadata.gz: 884f325e1aca01b0a5bb43b04c2b210c29b25c2d41935acabc5847a9cd08c74441e280419c24375436167d00d15b858fdf9745f7685550c5ec42b1d0be5517f2
7
+ data.tar.gz: f4dc5e666066ad131d0b41c37b6f77ec8ea02fd66ddf3bd6540a21cc6b43019632cb144e68471bba281b08c4d6e5cfc6005614360b7aa3ad1c4ffc3139ff3787
data/README.md CHANGED
@@ -8,24 +8,18 @@ http://www.subway.co.jp/campaign/tokusub/
8
8
 
9
9
  ## Installation
10
10
 
11
- Add this line to your application's Gemfile:
12
-
13
- gem 'tokusub'
14
-
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
11
  $ gem install tokusub
22
12
 
23
13
  ## Usage
24
14
 
25
- require 'tokusub'
15
+ ```ruby
16
+ require 'tokusub'
26
17
 
27
- TokuSub.get('mon') # => 'イベリコ豚の厚切りベーコン'
28
- TokuSub.get('tue') # => '炭火てり焼きチキン'
18
+ TokuSub.get('mon') #=> "イベリコ豚の厚切りベーコン"
19
+ TokuSub.get(:tue) #=> "炭火てり焼きチキン"
20
+ TokuSub.wed #=> "BLT"
21
+ TokuSub[:thu] #=> "ターキーブレスト"
22
+ ```
29
23
 
30
24
  ## Contributing
31
25
 
@@ -1,55 +1,47 @@
1
1
  # -*- coding: utf-8 -*-
2
-
3
2
  require 'nokogiri'
4
3
  require 'open-uri'
5
4
 
6
5
  module TokuSub
7
-
8
6
  class << self
9
-
10
7
  def get(weekday)
8
+ get_index[weekday.to_sym]
9
+ end
10
+
11
+ alias_method :[], :get
11
12
 
12
- return get_index[weekday]
13
-
13
+ %w(mon tue wed thu fri sat sun).each do |name|
14
+ define_method(name) { get(name) }
14
15
  end
15
16
 
16
17
  def get_index
17
-
18
18
  # get tokusub page
19
19
  tokusub_page = Nokogiri::HTML(open('http://www.subway.co.jp/campaign/tokusub/'))
20
-
21
20
  h = Hash::new
22
21
 
23
22
  # index tokusubs
24
23
  tokusub_page.css('li a img').each do |img|
25
-
26
24
  if img['src'] =~ /^images\/top_menu0/ then
27
-
28
25
  case img['src']
29
- when 'images/top_menu01.jpg' then
30
- h.store('mon', img['alt'])
31
- when 'images/top_menu02.jpg' then
32
- h.store('tue', img['alt'])
33
- when 'images/top_menu03.jpg' then
34
- h.store('wed', img['alt'])
35
- when 'images/top_menu04.jpg' then
36
- h.store('thu', img['alt'])
37
- when 'images/top_menu05.jpg' then
38
- h.store('fri', img['alt'])
39
- when 'images/top_menu06.jpg' then
40
- h.store('sat', img['alt'])
41
- when 'images/top_menu07.jpg' then
42
- h.store('sun', img['alt'])
26
+ when 'images/top_menu01.jpg'
27
+ h.store(:mon, img['alt'])
28
+ when 'images/top_menu02.jpg'
29
+ h.store(:tue, img['alt'])
30
+ when 'images/top_menu03.jpg'
31
+ h.store(:wed, img['alt'])
32
+ when 'images/top_menu04.jpg'
33
+ h.store(:thu, img['alt'])
34
+ when 'images/top_menu05.jpg'
35
+ h.store(:fri, img['alt'])
36
+ when 'images/top_menu06.jpg'
37
+ h.store(:sat, img['alt'])
38
+ when 'images/top_menu07.jpg'
39
+ h.store(:sun, img['alt'])
43
40
  end
44
-
45
- end
46
-
41
+ end
47
42
  end
48
-
49
- return h
50
43
 
44
+ h
51
45
  end
52
-
53
46
  end
54
-
55
47
  end
@@ -1,3 +1,3 @@
1
1
  module Tokusub
2
- VERSION = "0.0.2"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tokusub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - rinx