Class: Patentscope::PctPubNumber

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

Instance Method Summary collapse

Constructor Details

#initialize(number = "") ⇒ PctPubNumber

Returns a new instance of PctPubNumber.

Raises:



29
30
31
32
33
# File 'lib/patentscope/pct_doc_number.rb', line 29

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

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/patentscope/pct_doc_number.rb', line 35

def valid?
  self.match(/\A(([Ww][Oo]\/?)?\s?\d{4}\/?\s?\d{6})\Z/)
end

#validateObject



39
40
41
42
43
# File 'lib/patentscope/pct_doc_number.rb', line 39

def validate
  raise WrongNumberFormatError,
    "PCT publication number is not in correct format (WO/YYYY/NNNNNN)" unless valid?
  true
end