unicode_math 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4ddad12578490001d2c5fda8af73fab672f27539
4
+ data.tar.gz: e7d11e789c77d29010793fbd7051473923c6b8aa
5
+ SHA512:
6
+ metadata.gz: 3c893a8dd5572da2a8aa89f45ab342311ecbd52778bdbd13bae63f81e6c2ae6abcf9ca716a315b00687c8ae42a92d192255171987e0ba594211bb8c970f57d13
7
+ data.tar.gz: 4b0610cc0674ac6c4b1b70531a8d134a5c171feb50c7e18bddc9796c733ce3e278ed646f9db9e2e48eb73bcd5a02155db0432ca6726f7fd1ab3a8ff597427d83
data/.travis.yml CHANGED
@@ -1,10 +1,13 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.2
4
- - 1.9.3
3
+ - 2.1
4
+ - 2.2.4
5
+ - 2.3.0
6
+ - ruby-head
7
+ sudo: false
5
8
  script: rspec
6
9
  notifications:
7
10
  webhooks:
8
11
  urls:
9
12
  - http://buildlight.collectiveidea.com/
10
- on_start: true
13
+ on_start: always
data/README.md CHANGED
@@ -39,6 +39,19 @@ Easily use unicode costants:
39
39
  And have fun with them:
40
40
 
41
41
  (-∞..∞).cover? ∞ + 1
42
+
43
+ Including [Hindi numbers](https://en.wikibooks.org/wiki/Hindi/Numbers):
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
42
55
 
43
56
  ### Exponents
44
57
 
@@ -69,6 +82,11 @@ You can sum up or multiply emlements of either an array or range:
69
82
 
70
83
  [2, 3, 5, 7].∩ [3, 5, 7, 9]
71
84
  [2, 3, 5, 7].∪ [3, 5, 7, 9]
85
+
86
+ ### Factorial
87
+
88
+ 2.!
89
+ 10.!
72
90
 
73
91
  ## Installation
74
92
 
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rspec/core/rake_task'
3
3
 
4
+ Bundler::GemHelper.install_tasks(name: 'unicode_math')
4
5
  RSpec::Core::RakeTask.new
5
6
 
6
7
  task :default => :spec
@@ -31,6 +31,14 @@ module UnicodeMath
31
31
  define_method('∞') do
32
32
  1.0 / 0
33
33
  end
34
+
35
+ #Hindi Counting https://en.wikibooks.org/wiki/Hindi/Numbers
36
+ %w[० १ २ ३ ४ ५ ६ ७ ८ ९].map.with_index do |w,i|
37
+ define_method(w) do
38
+ i
39
+ end
40
+ end
41
+
34
42
  end
35
43
  end
36
44
  end
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+
3
+ module UnicodeMath
4
+ module Factorial
5
+ def self.included(base)
6
+ base.class_eval do
7
+ define_method('!') do
8
+ fact = 1
9
+ (self).downto(1) do |i|
10
+ fact = fact * i
11
+ end
12
+ fact
13
+ end
14
+
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ Numeric.send(:include, UnicodeMath::Factorial)
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+
3
+ module UnicodeMath
4
+ module FractionalOutput
5
+ def self.included(base)
6
+ base.class_eval do
7
+ alias_method :old_to_s, :to_s
8
+ def to_s
9
+ frac =
10
+ case self % 1
11
+ when ⅛ then '⅛'
12
+ when ⅙ then '⅙'
13
+ when ⅕ then '⅕'
14
+ when ¼ then '¼'
15
+ when ⅓ then '⅓'
16
+ when ⅜ then '⅜'
17
+ when ⅖ then '⅖'
18
+ when ½ then '½'
19
+ when ⅗ then '⅗'
20
+ when ⅝ then '⅝'
21
+ when ⅔ then '⅔'
22
+ when ⅘ then '⅘'
23
+ when ⅚ then '⅚'
24
+ when ¾ then '¾'
25
+ when ⅞ then '⅞'
26
+ else return old_to_s
27
+ end
28
+ "#{self >= 1 ? floor : ''}#{frac}"
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+ Float.send(:include, UnicodeMath::FractionalOutput)
@@ -0,0 +1,3 @@
1
+ module UnicodeMath
2
+ VERSION = "1.4.0"
3
+ end
@@ -22,4 +22,12 @@ describe UnicodeMath::Constants do
22
22
  it 'defines ∞' do
23
23
  expect(∞ + 1).to eq(∞)
24
24
  end
25
+
26
+ it 'defines १' do
27
+ expect(१).to eq(1)
28
+ end
29
+
30
+ it 'defines ३' do
31
+ expect(३).to eq(3)
32
+ end
25
33
  end
@@ -0,0 +1,17 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe UnicodeMath::Factorial do
6
+ it 'calculates factorial of 0' do
7
+ expect(0.!).to eq(1)
8
+ end
9
+
10
+ it 'calculate factorial' do
11
+ expect(2.!).to eq(2)
12
+ end
13
+
14
+ it 'calculates factorial' do
15
+ expect(4.!).to eq(24)
16
+ end
17
+ end
@@ -0,0 +1,75 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe UnicodeMath::FractionalOutput do
6
+ it 'displays one half as ½' do
7
+ expect((1.0/2).to_s).to eq('½')
8
+ end
9
+
10
+ describe 'thirds' do
11
+ it 'displays one third as ⅓' do
12
+ expect((1.0/3).to_s).to eq('⅓')
13
+ end
14
+
15
+ it 'displays two thirds as ⅔' do
16
+ expect((2.0/3).to_s).to eq('⅔')
17
+ end
18
+ end
19
+
20
+ describe 'quarters' do
21
+ it 'displays one quarter as ¼' do
22
+ expect((1.0/4).to_s).to eq('¼')
23
+ end
24
+
25
+ it 'displays three quarters as ¾' do
26
+ expect((3.0/4).to_s).to eq('¾')
27
+ end
28
+ end
29
+
30
+ describe 'fifths' do
31
+ it 'displays one fifth as ⅕' do
32
+ expect((1.0/5).to_s).to eq('⅕')
33
+ end
34
+
35
+ it 'displays two fifths as ⅖' do
36
+ expect((2.0/5).to_s).to eq('⅖')
37
+ end
38
+
39
+ it 'displays three fifths as ⅗' do
40
+ expect((3.0/5).to_s).to eq('⅗')
41
+ end
42
+
43
+ it 'displays four fifths as ⅘' do
44
+ expect((4.0/5).to_s).to eq('⅘')
45
+ end
46
+ end
47
+
48
+ describe 'sixths' do
49
+ it 'displays one sixth as ⅙' do
50
+ expect((1.0/6).to_s).to eq('⅙')
51
+ end
52
+
53
+ it 'displays five sixths as ⅚' do
54
+ expect((5.0/6).to_s).to eq('⅚')
55
+ end
56
+ end
57
+
58
+ describe 'eighths' do
59
+ it 'displays one eighth as ⅛' do
60
+ expect((1.0/8).to_s).to eq('⅛')
61
+ end
62
+
63
+ it 'displays three eighths as ⅜' do
64
+ expect((3.0/8).to_s).to eq('⅜')
65
+ end
66
+
67
+ it 'displays five eighths as ⅝' do
68
+ expect((5.0/8).to_s).to eq('⅝')
69
+ end
70
+
71
+ it 'displays seven eighths as ⅞' do
72
+ expect((7.0/8).to_s).to eq('⅞')
73
+ end
74
+ end
75
+ end
data/unicode_math.gemspec CHANGED
@@ -1,8 +1,10 @@
1
1
  # encoding: utf-8
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "unicode_math/version"
2
4
 
3
5
  Gem::Specification.new do |gem|
4
6
  gem.name = 'unicode_math'
5
- gem.version = '1.3.0'
7
+ gem.version = UnicodeMath::VERSION
6
8
 
7
9
  gem.author = 'Collective Idea'
8
10
  gem.email = 'info@collectiveidea.com'
metadata CHANGED
@@ -1,46 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unicode_math
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
5
- prerelease:
4
+ version: 1.4.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Collective Idea
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-12-22 00:00:00.000000000 Z
11
+ date: 2016-02-27 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rake
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '10.0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '10.0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rspec
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
33
  version: '2.12'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
40
  version: '2.12'
46
41
  description: Fun Ruby extensions for doing math with Unicode
@@ -49,8 +44,8 @@ executables: []
49
44
  extensions: []
50
45
  extra_rdoc_files: []
51
46
  files:
52
- - .gitignore
53
- - .travis.yml
47
+ - ".gitignore"
48
+ - ".travis.yml"
54
49
  - Gemfile
55
50
  - LICENSE.txt
56
51
  - README.md
@@ -59,18 +54,23 @@ files:
59
54
  - lib/unicode_math/constants.rb
60
55
  - lib/unicode_math/division.rb
61
56
  - lib/unicode_math/exponents.rb
57
+ - lib/unicode_math/factorial.rb
58
+ - lib/unicode_math/fractional_output.rb
62
59
  - lib/unicode_math/fractions.rb
63
60
  - lib/unicode_math/multiplication.rb
64
61
  - lib/unicode_math/roots.rb
65
62
  - lib/unicode_math/set.rb
66
63
  - lib/unicode_math/sigma.rb
67
64
  - lib/unicode_math/trigonometry.rb
65
+ - lib/unicode_math/version.rb
68
66
  - spec/spec_helper.rb
69
67
  - spec/support/random.rb
70
68
  - spec/unicode_math/constants_spec.rb
71
69
  - spec/unicode_math/division_spec.rb
72
70
  - spec/unicode_math/equations/euler_spec.rb
73
71
  - spec/unicode_math/exponents_spec.rb
72
+ - spec/unicode_math/factorial_spec.rb
73
+ - spec/unicode_math/fractional_output_spec.rb
74
74
  - spec/unicode_math/fractions_spec.rb
75
75
  - spec/unicode_math/multiplication_spec.rb
76
76
  - spec/unicode_math/root_spec.rb
@@ -80,33 +80,26 @@ files:
80
80
  - unicode_math.gemspec
81
81
  homepage: https://github.com/collectiveidea/unicode_math
82
82
  licenses: []
83
+ metadata: {}
83
84
  post_install_message:
84
85
  rdoc_options: []
85
86
  require_paths:
86
87
  - lib
87
88
  required_ruby_version: !ruby/object:Gem::Requirement
88
- none: false
89
89
  requirements:
90
- - - ! '>='
90
+ - - ">="
91
91
  - !ruby/object:Gem::Version
92
92
  version: '0'
93
- segments:
94
- - 0
95
- hash: 2351725633103773453
96
93
  required_rubygems_version: !ruby/object:Gem::Requirement
97
- none: false
98
94
  requirements:
99
- - - ! '>='
95
+ - - ">="
100
96
  - !ruby/object:Gem::Version
101
97
  version: '0'
102
- segments:
103
- - 0
104
- hash: 2351725633103773453
105
98
  requirements: []
106
99
  rubyforge_project:
107
- rubygems_version: 1.8.24
100
+ rubygems_version: 2.5.1
108
101
  signing_key:
109
- specification_version: 3
102
+ specification_version: 4
110
103
  summary: Fun Ruby extensions for doing math with Unicode
111
104
  test_files:
112
105
  - spec/spec_helper.rb
@@ -115,6 +108,8 @@ test_files:
115
108
  - spec/unicode_math/division_spec.rb
116
109
  - spec/unicode_math/equations/euler_spec.rb
117
110
  - spec/unicode_math/exponents_spec.rb
111
+ - spec/unicode_math/factorial_spec.rb
112
+ - spec/unicode_math/fractional_output_spec.rb
118
113
  - spec/unicode_math/fractions_spec.rb
119
114
  - spec/unicode_math/multiplication_spec.rb
120
115
  - spec/unicode_math/root_spec.rb