Class: Patentscope::PctAppNumber
- Inherits:
-
String
- Object
- String
- Patentscope::PctAppNumber
- Defined in:
- lib/patentscope/pct_doc_number.rb
Instance Method Summary collapse
-
#initialize(number = "") ⇒ PctAppNumber
constructor
A new instance of PctAppNumber.
- #to_ia_number ⇒ Object
- #valid? ⇒ Boolean
- #validate ⇒ Object
Constructor Details
#initialize(number = "") ⇒ PctAppNumber
Returns a new instance of PctAppNumber.
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_number ⇒ Object
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
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 |
#validate ⇒ Object
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 |