lib/plus_codes/open_location_code.rb
# Determines if a string is a valid sequence of Open Location Code(Plus+Codes) characters.
#
# @param code [String] a plus+codes
# @return [TrueClass, FalseClass] true if the code is valid, false otherwise
Determines if a string is a valid sequence of Open Location Code(Plus+Codes) characters.
Determines if a string is a valid sequence of Open Location Code ( Plus + Codes ) characters .
def valid_padding?(code)
      if code.include?(PADDING)
        return false if code.start_with?(PADDING)
        return false if code[-2..-1] != PADDING + SEPARATOR
        paddings = code.scan(/#{PADDING}+/)
        return false if !paddings.one? || paddings[0].length.odd?
        return false if paddings[0].length > SEPARATOR_POSITION - 2
      end
      true
    end
def valid_padding? ( code ) if code . include? ( PADDING ) return false if code . start_with? ( PADDING ) return false if code [ - 2 .. - 1 ] != PADDING + SEPARATOR paddings = code . scan ( / #{ PADDING } + / ) return false if ! paddings . one? || paddings [ 0 ] . length . odd? return false if paddings [ 0 ] . length > SEPARATOR_POSITION - 2 end true end
Determines if a string is a valid sequence of Open Location Code(Plus+Codes) characters.
Determines if a string is a valid sequence of Open Location Code ( Plus + Codes ) characters .
true if the code is valid, false otherwise
true if the code is valid false otherwise
TrueClass, FalseClass
code
None