class UnitedStates::State::Name

A state name, requires the name be given on initialization.

Public Class Methods

new(string) click to toggle source

@param string [String]

the name of the State

@return [UnitedStates::State::Name]

# File lib/united_states/state/name.rb, line 10
def initialize(string)
  @string = string.to_s
end

Public Instance Methods

==(other) click to toggle source

@param other [UnitedStates::State::Name] @return [Boolean]

whether or not other.to_s matches self.to_s
# File lib/united_states/state/name.rb, line 17
def ==(other)
  other.to_s == to_s
end
camel_case() click to toggle source

@return [String]

the State's name with a leading lower case letter
and each following word capitalized with no separation.
# File lib/united_states/state/name.rb, line 24
def camel_case
  "#{pascal_case[0, 1].downcase}#{pascal_case[1..-1]}"
end
capitalize() click to toggle source

@return [String]

the State's name with a leading capital letter.
# File lib/united_states/state/name.rb, line 30
def capitalize
  @string.split.map(&:capitalize).join(' ')
end
lowercase() click to toggle source

@return [String]

the State's name in all lowercase letters.
# File lib/united_states/state/name.rb, line 36
def lowercase
  @string.downcase
end
pascal_case() click to toggle source

@return [String]

the State's name with each word with a leading capital letter
with no separation.
# File lib/united_states/state/name.rb, line 43
def pascal_case
  capitalize.tr(' ', '')
end
screaming_snake_case() click to toggle source

@return [String]

the State's name all uppercase and separated by underscores.
# File lib/united_states/state/name.rb, line 49
def screaming_snake_case
  snake_case.upcase
end
snake_case() click to toggle source

@return [String]

the State's name all lowercase and separated by underscores.
# File lib/united_states/state/name.rb, line 55
def snake_case
  lowercase.tr(' ', '_')
end
to_s() click to toggle source

@return [String]

the State's name with a leading capital letter.
# File lib/united_states/state/name.rb, line 61
def to_s
  capitalize
end