Class: MKBrut::AppName
- Inherits:
-
Object
- Object
- MKBrut::AppName
- Defined in:
- lib/mkbrut/app_name.rb
Instance Method Summary collapse
-
#initialize(value) ⇒ AppName
constructor
A new instance of AppName.
- #to_s ⇒ Object (also: #to_str)
Constructor Details
#initialize(value) ⇒ AppName
Returns a new instance of AppName.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/mkbrut/app_name.rb', line 3 def initialize(value) identifier = value.to_s if identifier.empty? raise MKBrut::InvalidIdentifier, "app-name is required" end if identifier.length > 63 raise MKBrut::InvalidIdentifier, "app-name cannot be longer than 63 characters" end if identifier.start_with?("-") || identifier.end_with?("-") raise MKBrut::InvalidIdentifier, "app-name cannot start or end with a hyphen" end if identifier.match?(/[^a-zA-Z\-_]/) raise MKBrut::InvalidIdentifier, "app-name can only contain letters, hyphens, and underscores" end if identifier.match?(/__/) || identifier.match?(/--/) raise MKBrut::InvalidIdentifier, "app-name can not have repeating underscores or hyphens" end @identifier = identifier.to_s.gsub(/_/,"-") end |
Instance Method Details
#to_s ⇒ Object Also known as: to_str
26 |
# File 'lib/mkbrut/app_name.rb', line 26 def to_s = @identifier |