better_bart 0.0.31 → 0.0.32

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.
File without changes
data/lib/bart.rb CHANGED
@@ -7,6 +7,7 @@ module Bart
7
7
  API_HOST = 'api.bart.gov'
8
8
  SCRIPT_URLS = {
9
9
  :routes => 'route.aspx',
10
+ :stations => 'stn.aspx',
10
11
  :etd => 'etd.aspx'
11
12
  }
12
13
 
@@ -34,7 +35,34 @@ module Bart
34
35
  end
35
36
  route
36
37
  end
37
- routes
38
+
39
+ return routes if route_num.nil?
40
+ routes[0]
41
+ end
42
+
43
+ def self.stations orig = nil
44
+ params = {}
45
+ if orig.nil?
46
+ params[:cmd] = 'stns'
47
+ else
48
+ params[:cmd] = 'stninfo'
49
+ params[:orig] = orig
50
+ end
51
+
52
+ path = self.path_for :stations, params
53
+ xml = self.get_xml path
54
+
55
+ stations = xml.css('stations').css('station').collect do |s|
56
+ station = {}
57
+ s.children.each do |s|
58
+ station[s.name.to_sym] = s.text
59
+ end
60
+
61
+ station
62
+ end
63
+
64
+ return stations if orig.nil?
65
+ stations[0]
38
66
  end
39
67
 
40
68
  def self.real_time_info orig, additional_params = nil
@@ -46,8 +74,6 @@ module Bart
46
74
  params = params.merge(additional_params)
47
75
  end
48
76
 
49
- puts params
50
-
51
77
  path = self.path_for :etd, params
52
78
  xml = self.get_xml path
53
79
 
@@ -72,4 +98,8 @@ module Bart
72
98
  def self.get_xml path
73
99
  Nokogiri::XML.parse(self.get(path))
74
100
  end
101
+
102
+ def self.get_xml_and_path_for what, params
103
+ self.get_xml(self.path_for(what, params))
104
+ end
75
105
  end
data/lib/bart/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Bart
2
- VERSION = "0.0.31"
2
+ VERSION = "0.0.32"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: better_bart
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.31
4
+ version: 0.0.32
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,23 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
  date: 2012-10-19 00:00:00.000000000 Z
13
- dependencies: []
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: nokogiri
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
14
30
  description: Intuitive analog to BART's API
15
31
  email:
16
32
  - bennyjbergstein@gmail.com
@@ -23,7 +39,7 @@ files:
23
39
  - LICENSE
24
40
  - README.md
25
41
  - Rakefile
26
- - bart.gemspec
42
+ - better_bart.gemspec
27
43
  - lib/bart.rb
28
44
  - lib/bart/version.rb
29
45
  homepage: