Class: Patentscope::PctAppNumber

Inherits:
String
  • Object
show all
Defined in:
lib/patentscope/pct_doc_number.rb

Instance Method Summary collapse

Constructor Details

#initialize(number = "") ⇒ PctAppNumber

Returns a new instance of PctAppNumber.

Raises:

  • (NoNumberError)


5
6
7
8
9
# File 'lib/patentscope/pct_doc_number.rb', line 5

def initialize(number = "")
  raise NoNumberError,
    "Patent application number was not entered" if number.nil?
  super(number.strip)
end

Instance Method Details

#to_ia_numberObject



20
21
22
23
24
25
# File 'lib/patentscope/pct_doc_number.rb', line 20

def to_ia_number
  self.upcase!
  self.gsub!('/', '')
  self.gsub!('PCT', '')
  self
end

#valid?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/patentscope/pct_doc_number.rb', line 11

def valid?
  self.match(/\A(([Pp][Cc][Tt]\/?)?[a-zA-Z]{2}\d{4}\/?\d{6})\Z/)
end

#validateObject



15
16
17
18
# File 'lib/patentscope/pct_doc_number.rb', line 15

def validate
  raise WrongNumberFormatError,
    "PCT application number is not in correct format (PCT/CCYYYY/NNNNNN)" unless valid?
end