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:

  • (NoNumberError)


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

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

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


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

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

#validateObject



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

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