Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

put in a better namespace

  • Loading branch information...
commit b3e0fd0684935712df9edd2ec65d80a08cd5a84d 1 parent 1501bfe
@rafaelss authored
View
1  lib/cielo.rb
@@ -7,7 +7,6 @@ module Cielo
autoload :Shop, "cielo/shop"
autoload :Order, "cielo/order"
autoload :Payment, "cielo/payment"
- autoload :Validity, "cielo/validity"
autoload :Card, "cielo/card"
autoload :TransactionRequest, "cielo/transaction_request"
View
2  lib/cielo/card.rb
@@ -1,3 +1,5 @@
+require "cielo/card/validity"
+
module Cielo
class Card
include HappyMapper
View
21 lib/cielo/card/validity.rb
@@ -0,0 +1,21 @@
+module Cielo
+ class Card
+ class Validity
+ class InvalidDate < StandardError; end
+
+ def initialize(year, month)
+ @year = year.to_i
+ @month = month.to_i
+
+ now = Time.now
+ if @year < now.year || @month < now.month
+ raise InvalidDate, "#{@month}/#{@year} is not valid"
+ end
+ end
+
+ def to_s
+ [@year, "%02d" % @month].join
+ end
+ end
+ end
+end
View
19 lib/cielo/validity.rb
@@ -1,19 +0,0 @@
-module Cielo
- class Validity
- class InvalidDate < StandardError; end
-
- def initialize(year, month)
- @year = year.to_i
- @month = month.to_i
-
- now = Time.now
- if @year < now.year || @month < now.month
- raise InvalidDate, "#{@month}/#{@year} is not valid"
- end
- end
-
- def to_s
- [@year, "%02d" % @month].join
- end
- end
-end
View
2  spec/cielo/card_spec.rb
@@ -5,7 +5,7 @@
it "#to_xml" do
subject.number = "4012001037141112"
- subject.validity = Cielo::Validity.new(2015, 11)
+ subject.validity = Cielo::Card::Validity.new(2015, 11)
subject.indicator = 1
subject.security_code = 371
subject.owner = "FULANO DE TAL"
View
2  spec/cielo/validity_spec.rb
@@ -1,6 +1,6 @@
require "spec_helper"
-describe Cielo::Validity do
+describe Cielo::Card::Validity do
before do
Timecop.freeze(Time.parse("2012-05-14 09:23:00"))
end
Please sign in to comment.
Something went wrong with that request. Please try again.