Class: Pdfh::DocumentType
- Inherits:
-
Struct
- Object
- Struct
- Pdfh::DocumentType
- Defined in:
- lib/pdfh/models/document_type.rb
Overview
Represents a type of document that can be processed by pdfh
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#name_template ⇒ Object
Returns the value of attribute name_template.
-
#print_cmd ⇒ Object
Returns the value of attribute print_cmd.
-
#pwd ⇒ Object
Returns the value of attribute pwd.
-
#re_date ⇒ Object
Returns the value of attribute re_date.
-
#re_file ⇒ Object
Returns the value of attribute re_file.
-
#store_path ⇒ Object
Returns the value of attribute store_path.
-
#sub_types ⇒ Object
Returns the value of attribute sub_types.
Instance Method Summary collapse
- #generate_new_name(values) ⇒ String
- #generate_path(values) ⇒ String
-
#gid ⇒ String
removes special characters from string and replaces spaces with dashes.
- #initialize(args) ⇒ self constructor
- #password ⇒ String
- #sub_type(text) ⇒ DocumentSubType
Constructor Details
#initialize(args) ⇒ self
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/pdfh/models/document_type.rb', line 8 def initialize(args) super self.name_template ||= "{original}" self.re_file = Regexp.new(re_file) self.re_date = Regexp.new(re_date) self.sub_types = extract_subtype(sub_types) if sub_types @path_validator = RenameValidator.new(store_path) @name_validator = RenameValidator.new(name_template) return if @path_validator.valid? && @name_validator.valid? raise_validators_error end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name
5 6 7 |
# File 'lib/pdfh/models/document_type.rb', line 5 def name @name end |
#name_template ⇒ Object
Returns the value of attribute name_template
5 6 7 |
# File 'lib/pdfh/models/document_type.rb', line 5 def name_template @name_template end |
#print_cmd ⇒ Object
Returns the value of attribute print_cmd
5 6 7 |
# File 'lib/pdfh/models/document_type.rb', line 5 def print_cmd @print_cmd end |
#pwd ⇒ Object
Returns the value of attribute pwd
5 6 7 |
# File 'lib/pdfh/models/document_type.rb', line 5 def pwd @pwd end |
#re_date ⇒ Object
Returns the value of attribute re_date
5 6 7 |
# File 'lib/pdfh/models/document_type.rb', line 5 def re_date @re_date end |
#re_file ⇒ Object
Returns the value of attribute re_file
5 6 7 |
# File 'lib/pdfh/models/document_type.rb', line 5 def re_file @re_file end |
#store_path ⇒ Object
Returns the value of attribute store_path
5 6 7 |
# File 'lib/pdfh/models/document_type.rb', line 5 def store_path @store_path end |
#sub_types ⇒ Object
Returns the value of attribute sub_types
5 6 7 |
# File 'lib/pdfh/models/document_type.rb', line 5 def sub_types @sub_types end |
Instance Method Details
#generate_new_name(values) ⇒ String
45 46 47 |
# File 'lib/pdfh/models/document_type.rb', line 45 def generate_new_name(values) @name_validator.gsub(values) end |
#generate_path(values) ⇒ String
51 52 53 |
# File 'lib/pdfh/models/document_type.rb', line 51 def generate_path(values) @path_validator.gsub(values) end |
#gid ⇒ String
removes special characters from string and replaces spaces with dashes
26 27 28 |
# File 'lib/pdfh/models/document_type.rb', line 26 def gid name.downcase.gsub(/[^0-9A-Za-z\s]/, "").tr(" ", "-") end |
#password ⇒ String
37 38 39 40 41 |
# File 'lib/pdfh/models/document_type.rb', line 37 def password return Base64.decode64(pwd) if base64? pwd end |
#sub_type(text) ⇒ DocumentSubType
31 32 33 34 |
# File 'lib/pdfh/models/document_type.rb', line 31 def sub_type(text) # Regexp.new(st.name).match?(name) sub_types&.find { |st| /#{st.name}/i.match?(text) } end |