oeis 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ require 'oeis'
2
+
3
+ numbers = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten']
4
+ res = OEIS::search(numbers.collect { |item| item.length })
5
+
6
+ puts "#{res.id}: #{res.title}"
7
+ puts res.sequence[0..30].inspect
@@ -0,0 +1,14 @@
1
+ require 'oeis'
2
+
3
+ def digit_sum(n)
4
+ if n < 10
5
+ n
6
+ else
7
+ n % 10 + digit_sum(n / 10)
8
+ end
9
+ end
10
+
11
+ res = OEIS::search(1.upto(30).map { |n| digit_sum(n) })
12
+
13
+ puts "#{res.id}: #{res.title}"
14
+ puts res.sequence[0..30].inspect
data/lib/oeis.rb CHANGED
@@ -14,15 +14,15 @@ module OEIS
14
14
  doc = Nokogiri::HTML(open(url))
15
15
 
16
16
  first_result = doc.css('table table:eq(2)').first
17
- info = first_result.css('tr:eq(3) table > tr > td > a').first
17
+ info = first_result.css('tr:eq(3) table > tr').first
18
18
 
19
19
  if info.nil?
20
20
  puts 'No sequence found.'
21
21
  return nil
22
22
  end
23
23
 
24
- @id = info.attributes['href'].value[1..-1]
25
- @title = info.attributes['title'].value
24
+ @id = info.css('td:eq(1) > a').text.strip
25
+ @title = info.css('td:eq(3)').text.strip
26
26
 
27
27
  digits = first_result.css('tr:eq(4) table tr tt').text.split(', ')
28
28
  @sequence = digits.map &:to_i
data/lib/oeis/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module OEIS
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oeis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-23 00:00:00.000000000Z
12
+ date: 2013-02-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
16
- requirement: &70156756845880 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,7 +21,12 @@ dependencies:
21
21
  version: '1.4'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70156756845880
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.4'
25
30
  description: Allows you to fetch results from OEIS using a list of integers
26
31
  email:
27
32
  - scalesjordan@gmail.com
@@ -33,6 +38,8 @@ files:
33
38
  - Gemfile
34
39
  - README.md
35
40
  - Rakefile
41
+ - examples/english-numbers.rb
42
+ - examples/sum-of-digits.rb
36
43
  - examples/thue-morse.rb
37
44
  - lib/oeis.rb
38
45
  - lib/oeis/version.rb
@@ -57,8 +64,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
57
64
  version: '0'
58
65
  requirements: []
59
66
  rubyforge_project: oeis
60
- rubygems_version: 1.8.6
67
+ rubygems_version: 1.8.24
61
68
  signing_key:
62
69
  specification_version: 3
63
70
  summary: On-Line Encyclopedia of Integer Sequences gem
64
71
  test_files: []
72
+ has_rdoc: