Class: CoaOpScraper::CoaDocketNo
- Inherits:
-
Object
- Object
- CoaOpScraper::CoaDocketNo
- Defined in:
- lib/coa_docket_no.rb
Instance Attribute Summary collapse
-
#no ⇒ Object
Returns the value of attribute no.
Instance Method Summary collapse
- #canonical ⇒ Object
- #case_number ⇒ Object
- #civil? ⇒ Boolean
-
#coa_number ⇒ Object
For accessing pieces.
- #criminal? ⇒ Boolean
- #fixed_length ⇒ Object
-
#for_database_key ⇒ Object
Standardizing how used internally.
-
#for_web_urls ⇒ Object
because the -CV/-CR suffix is not relevant to uniqueness.
-
#initialize(no) ⇒ CoaDocketNo
constructor
Encapsulating the logic of working with COA docket numbers.
- #to_s ⇒ Object
- #valid? ⇒ Boolean
- #without_type ⇒ Object
- #year_number ⇒ Object
Constructor Details
#initialize(no) ⇒ CoaDocketNo
Encapsulating the logic of working with COA docket numbers. Note: Distinct from knowing if a valid docket number was actually used
7 8 9 10 11 12 13 14 |
# File 'lib/coa_docket_no.rb', line 7 def initialize(no) parts = no.split("-") if parts.count == 4 and (parts.last == "CR" or parts.last == "CV") @no = no else @no = nil end end |
Instance Attribute Details
#no ⇒ Object
Returns the value of attribute no.
3 4 5 |
# File 'lib/coa_docket_no.rb', line 3 def no @no end |
Instance Method Details
#canonical ⇒ Object
72 73 74 |
# File 'lib/coa_docket_no.rb', line 72 def canonical self.fixed_length end |
#case_number ⇒ Object
48 49 50 |
# File 'lib/coa_docket_no.rb', line 48 def case_number self.canonical.split("-")[2] end |
#civil? ⇒ Boolean
52 53 54 |
# File 'lib/coa_docket_no.rb', line 52 def civil? self.canonical.split("-")[3] == "CV" end |
#coa_number ⇒ Object
For accessing pieces
40 41 42 |
# File 'lib/coa_docket_no.rb', line 40 def coa_number self.canonical.split("-")[0] end |
#criminal? ⇒ Boolean
56 57 58 |
# File 'lib/coa_docket_no.rb', line 56 def criminal? self.canonical.split("-")[3] == "CR" end |
#fixed_length ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/coa_docket_no.rb', line 24 def fixed_length if self.valid? (coa,year,number,type_suffix) = @no.split("-") [padded(coa,2), padded(year,2), padded(number,5), type_suffix].join('-') else "" end end |
#for_database_key ⇒ Object
Standardizing how used internally
63 64 65 |
# File 'lib/coa_docket_no.rb', line 63 def for_database_key self.without_type end |
#for_web_urls ⇒ Object
because the -CV/-CR suffix is not relevant to uniqueness
68 69 70 |
# File 'lib/coa_docket_no.rb', line 68 def for_web_urls self.fixed_length end |
#to_s ⇒ Object
20 21 22 |
# File 'lib/coa_docket_no.rb', line 20 def to_s self.fixed_length end |
#valid? ⇒ Boolean
16 17 18 |
# File 'lib/coa_docket_no.rb', line 16 def valid? !@no.nil? end |
#without_type ⇒ Object
33 34 35 |
# File 'lib/coa_docket_no.rb', line 33 def without_type self.fixed_length.sub("-CR","").sub("-CV","") end |
#year_number ⇒ Object
44 45 46 |
# File 'lib/coa_docket_no.rb', line 44 def year_number self.canonical.split("-")[1] end |