Class: EgovUtils::Fileuid::Type
- Inherits:
-
Object
- Object
- EgovUtils::Fileuid::Type
- Defined in:
- lib/egov_utils/fileuid.rb
Instance Attribute Summary collapse
-
#snippets ⇒ Object
readonly
Returns the value of attribute snippets.
Instance Method Summary collapse
- #file_uid_to_s(fileuid) ⇒ Object
-
#initialize(*attrs) ⇒ Type
constructor
A new instance of Type.
- #snippet_names ⇒ Object
- #to_regex ⇒ Object
- #to_regex_s ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(*attrs) ⇒ Type
Returns a new instance of Type.
52 53 54 |
# File 'lib/egov_utils/fileuid.rb', line 52 def initialize(*attrs) @snippets = attrs end |
Instance Attribute Details
#snippets ⇒ Object (readonly)
Returns the value of attribute snippets.
50 51 52 |
# File 'lib/egov_utils/fileuid.rb', line 50 def snippets @snippets end |
Instance Method Details
#file_uid_to_s(fileuid) ⇒ Object
72 73 74 |
# File 'lib/egov_utils/fileuid.rb', line 72 def file_uid_to_s(fileuid) snippets.collect{|snippet| snippet.static? ? snippet.name : fileuid.public_send(snippet.name) }.join end |
#snippet_names ⇒ Object
56 57 58 |
# File 'lib/egov_utils/fileuid.rb', line 56 def snippet_names snippets.select{|s| !s.static? }.collect{|s| s.name} end |
#to_regex ⇒ Object
68 69 70 |
# File 'lib/egov_utils/fileuid.rb', line 68 def to_regex /\A#{to_regex_s}\z/ end |
#to_regex_s ⇒ Object
64 65 66 |
# File 'lib/egov_utils/fileuid.rb', line 64 def to_regex_s snippets.collect{|s| (s.type == :static ? s.to_regex_s : "(#{s.to_regex_s})") }.join() end |
#validate! ⇒ Object
60 61 62 |
# File 'lib/egov_utils/fileuid.rb', line 60 def validate! raise "Snippet names for file uid type has to be uniq!" unless snippet_names.length == snippet_names.uniq.length end |