Class: EgovUtils::Fileuid::Snippet
- Inherits:
-
Struct
- Object
- Struct
- EgovUtils::Fileuid::Snippet
- Defined in:
- lib/egov_utils/fileuid.rb
Instance Attribute Summary collapse
-
#length ⇒ Object
Returns the value of attribute length.
-
#mandatory ⇒ Object
Returns the value of attribute mandatory.
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #length_to_regex_part ⇒ Object
- #mandatory? ⇒ Boolean
- #static? ⇒ Boolean
- #to_regex_s ⇒ Object
- #type_to_regex_part ⇒ Object
Instance Attribute Details
#length ⇒ Object
Returns the value of attribute length
4 5 6 |
# File 'lib/egov_utils/fileuid.rb', line 4 def length @length end |
#mandatory ⇒ Object
Returns the value of attribute mandatory
4 5 6 |
# File 'lib/egov_utils/fileuid.rb', line 4 def mandatory @mandatory end |
#name ⇒ Object
Returns the value of attribute name
4 5 6 |
# File 'lib/egov_utils/fileuid.rb', line 4 def name @name end |
#type ⇒ Object
Returns the value of attribute type
4 5 6 |
# File 'lib/egov_utils/fileuid.rb', line 4 def type @type end |
Instance Method Details
#length_to_regex_part ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/egov_utils/fileuid.rb', line 29 def length_to_regex_part case length when 1, nil '' when :any mandatory? ? "+" : "*" when Array "{#{length[0]},#{length[1]}}" when Numeric "{#{length}}" else length end end |
#mandatory? ⇒ Boolean
6 7 8 |
# File 'lib/egov_utils/fileuid.rb', line 6 def mandatory? mandatory.nil? ? true : mandatory end |
#static? ⇒ Boolean
10 11 12 |
# File 'lib/egov_utils/fileuid.rb', line 10 def static? type == :static end |
#to_regex_s ⇒ Object
44 45 46 |
# File 'lib/egov_utils/fileuid.rb', line 44 def to_regex_s type_to_regex_part + length_to_regex_part end |
#type_to_regex_part ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/egov_utils/fileuid.rb', line 14 def type_to_regex_part case type when String type when :integer "\\d" when :word "\\w" when :static name else raise "Unsuported fileuid snippet type #{type}" end end |