safai 0.0.4 → 0.0.5

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.
data/lib/safai/clean.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  class Safai::Clean
2
2
 
3
+ # Standardize how web URLs are presented
3
4
  def self.url(link)
4
5
  link = link.gsub("http://", "")
5
6
  link = link.gsub("https://", "")
@@ -7,4 +8,10 @@ class Safai::Clean
7
8
  return "http://#{link}"
8
9
  end
9
10
 
11
+ # Remove the unnecessary .0 that gets added to floated strings
12
+ def self.floated_string(f)
13
+ f = f.to_s
14
+ return f.index(".0").nil? ? f : f[0, f.index(".0")]
15
+ end
16
+
10
17
  end
@@ -0,0 +1,12 @@
1
+ class Safai::Money
2
+
3
+ def self.return_money(iso_numeric)
4
+ Money::Currency.table.map.each do |m|
5
+ if m[1][:iso_numeric] == iso_numeric
6
+ return m
7
+ end
8
+ end
9
+ return nil
10
+ end
11
+
12
+ end
data/lib/safai.rb CHANGED
@@ -30,8 +30,14 @@ class Safai
30
30
  end
31
31
 
32
32
  def amt(c, amount)
33
+ m = Money::Currency.new(c)
33
34
  amount = sprintf("%0.02f", amount)
34
- return c == "USD" ? "$#{amount.to_s}" : "Rs.#{amount.to_s}"
35
+ if !m.blank?
36
+ if !m.symbol.blank?
37
+ return "#{m.symbol} #{amount.to_s}".html_safe
38
+ end
39
+ end
40
+ return "#{c} #{amount.to_s}"
35
41
  end
36
42
 
37
43
  end
@@ -93,5 +99,6 @@ require 'safai/address'
93
99
  require 'safai/regex'
94
100
  require 'safai/clean'
95
101
  require 'safai/gravatar'
102
+ require 'safai/money'
96
103
  ActionView::Base.send :include, Safai::Helpers
97
104
  ActionView::Base.send :include, Safai::DeviseHelpers
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: safai
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:
@@ -39,6 +39,7 @@ files:
39
39
  - lib/safai/address.rb
40
40
  - lib/safai/clean.rb
41
41
  - lib/safai/gravatar.rb
42
+ - lib/safai/money.rb
42
43
  homepage: http://rubygems.org/gems/safai
43
44
  licenses: []
44
45
  post_install_message: