Sha256: fd44b79d3ed4c4fe88aa7c536e04d896f06d612ee5320707c83e51e856137dec

Contents?: true

Size: 733 Bytes

Versions: 10

Compression:

Stored size: 733 Bytes

Contents

module PagSeguro
  class Sender
    attr_accessor :name, :email, :phone_ddd, :phone_number
    
    def initialize(options = {})
      @name         = options[:name]
      @email        = options[:email]
      @phone_ddd    = options[:phone_ddd]
      @phone_number = options[:phone_number]
    end
    
    def email
      valid_email? ? @email : nil
    end

    def valid_email?
      @email =~ /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i && @email.size <= 60
    end
    
    def name
      ( @name.present? && @name.size > 50 ) ? @name[0..49] : @name
    end
    
    def phone_ddd
      @phone_ddd if @phone_ddd =~ /^\d{2}$/
    end
    
    def phone_number
      @phone_number if @phone_number =~/^\d{8}$/
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
pag_seguro-0.2.0 lib/pag_seguro/sender.rb
pag_seguro-0.1.9 lib/pag_seguro/sender.rb
pag_seguro-0.1.8 lib/pag_seguro/sender.rb
pag_seguro-0.1.7 lib/pag_seguro/sender.rb
pag_seguro-0.1.6 lib/pag_seguro/sender.rb
pag_seguro-0.1.4 lib/pag_seguro/sender.rb
pag_seguro-0.1.3 lib/pag_seguro/sender.rb
pag_seguro-0.1.2 lib/pag_seguro/sender.rb
pag_seguro-0.1.1 lib/pag_seguro/sender.rb
pag_seguro-0.1.0 lib/pag_seguro/sender.rb