lib/lucky_case/string.rb in lucky_case-0.2.1 vs lib/lucky_case/string.rb in lucky_case-0.2.2
- old
+ new
@@ -44,15 +44,22 @@
def convert_case!(case_type, preserve_prefixed_underscores: true)
set_self_value self.convert_case(case_type, preserve_prefixed_underscores: preserve_prefixed_underscores)
end
+ # Check if the string matches any of the available cases
+ #
+ # @return [Boolean]
+ def valid_case_string?()
+ LuckyCase.case(self) != nil
+ end
+
#----------------------------------------------------------------------------------------------------
# UPPER CASE
#----------------------------------------------------------------------------------------------------
- # Converts all characters inside the string
+ # Convert all characters inside the string
# into upper case
#
# @example conversion
# 'this-isAnExample_string' => 'THIS-ISANEXAMPLE_STRING'
#
@@ -63,22 +70,22 @@
def upper_case!()
set_self_value self.upper_case
end
- # Checks if all characters inside the string are upper case
+ # Check if all characters inside the string are upper case
#
# @return [Boolean]
def upper_case?()
LuckyCase.upper_case? self
end
#----------------------------------------------------------------------------------------------------
# LOWER CASE
#----------------------------------------------------------------------------------------------------
- # Converts all characters inside the string
+ # Convert all characters inside the string
# into lower case
#
# @example conversion
# 'this-isAnExample_string' => 'this-isanexample_string'
#
@@ -89,22 +96,22 @@
def lower_case!()
set_self_value self.lower_case
end
- # Checks if all characters inside the string are lower case
+ # Check if all characters inside the string are lower case
#
# @return [Boolean]
def lower_case?()
LuckyCase.lower_case? self
end
#----------------------------------------------------------------------------------------------------
# SNAKE CASE
#----------------------------------------------------------------------------------------------------
- # Converts the given string from any case
+ # Convert the given string from any case
# into snake case
#
# @example conversion
# 'this-isAnExample_string' => 'this_is_an_example_string'
#
@@ -116,19 +123,19 @@
def snake_case!(preserve_prefixed_underscores: true)
set_self_value self.snake_case preserve_prefixed_underscores: preserve_prefixed_underscores
end
- # Checks if the string is snake case
+ # Check if the string is snake case
#
# @param [Boolean] allow_prefixed_underscores
# @return [Boolean]
def snake_case?(allow_prefixed_underscores: true)
LuckyCase.snake_case? self, allow_prefixed_underscores: allow_prefixed_underscores
end
- # Converts the given string from any case
+ # Convert the given string from any case
# into upper snake case
#
# @example conversion
# 'this-isAnExample_string' => 'THIS_IS_AN_EXAMPLE_STRING'
#
@@ -140,11 +147,11 @@
def upper_snake_case!(preserve_prefixed_underscores: true)
set_self_value self.upper_snake_case preserve_prefixed_underscores: preserve_prefixed_underscores
end
- # Checks if the string is upper snake case
+ # Check if the string is upper snake case
#
# @param [Boolean] allow_prefixed_underscores
# @return [Boolean]
def upper_snake_case?(allow_prefixed_underscores: true)
LuckyCase.upper_snake_case? self, allow_prefixed_underscores: allow_prefixed_underscores
@@ -152,11 +159,11 @@
#----------------------------------------------------------------------------------------------------
# PASCAL CASE
#----------------------------------------------------------------------------------------------------
- # Converts the given string from any case
+ # Convert the given string from any case
# into pascal case
#
# @example conversion
# 'this-isAnExample_string' => 'ThisIsAnExampleString'
#
@@ -168,11 +175,11 @@
def pascal_case!(preserve_prefixed_underscores: true)
set_self_value self.pascal_case preserve_prefixed_underscores: preserve_prefixed_underscores
end
- # Checks if the string is upper pascal case
+ # Check if the string is upper pascal case
#
# @param [Boolean] allow_prefixed_underscores
# @return [Boolean]
def pascal_case?(allow_prefixed_underscores: true)
LuckyCase.pascal_case? self, allow_prefixed_underscores: allow_prefixed_underscores
@@ -180,11 +187,11 @@
#----------------------------------------------------------------------------------------------------
# CAMEL CASE
#----------------------------------------------------------------------------------------------------
- # Converts the given string from any case
+ # Convert the given string from any case
# into camel case
#
# @example conversion
# 'this-isAnExample_string' => 'thisIsAnExampleString'
#
@@ -196,11 +203,11 @@
def camel_case!(preserve_prefixed_underscores: true)
set_self_value self.camel_case preserve_prefixed_underscores: preserve_prefixed_underscores
end
- # Checks if the string is camel case
+ # Check if the string is camel case
#
# @param [Boolean] allow_prefixed_underscores
# @return [Boolean]
def camel_case?(allow_prefixed_underscores: true)
LuckyCase.camel_case? self, allow_prefixed_underscores: allow_prefixed_underscores
@@ -208,11 +215,11 @@
#----------------------------------------------------------------------------------------------------
# DASH CASE
#----------------------------------------------------------------------------------------------------
- # Converts the given string from any case
+ # Convert the given string from any case
# into dash case
#
# @example conversion
# 'this-isAnExample_string' => 'this-is-an-example-string'
#
@@ -224,19 +231,19 @@
def dash_case!(preserve_prefixed_underscores: true)
set_self_value self.dash_case preserve_prefixed_underscores: preserve_prefixed_underscores
end
- # Checks if the string is dash case
+ # Check if the string is dash case
#
# @param [Boolean] allow_prefixed_underscores
# @return [Boolean]
def dash_case?(allow_prefixed_underscores: true)
LuckyCase.dash_case? self, allow_prefixed_underscores: allow_prefixed_underscores
end
- # Converts the given string from any case
+ # Convert the given string from any case
# into upper dash case
#
# @example conversion
# 'this-isAnExample_string' => 'THIS-IS-AN-EXAMPLE-STRING'
#
@@ -248,11 +255,11 @@
def upper_dash_case!(preserve_prefixed_underscores: true)
set_self_value self.upper_dash_case preserve_prefixed_underscores: preserve_prefixed_underscores
end
- # Checks if the string is upper dash case
+ # Check if the string is upper dash case
#
# @param [Boolean] allow_prefixed_underscores
# @return [Boolean]
def upper_dash_case?(allow_prefixed_underscores: true)
LuckyCase.upper_dash_case? self, allow_prefixed_underscores: allow_prefixed_underscores
@@ -260,11 +267,11 @@
#----------------------------------------------------------------------------------------------------
# TRAIN CASE
#----------------------------------------------------------------------------------------------------
- # Converts the given string from any case
+ # Convert the given string from any case
# into train case
#
# @example conversion
# 'this-isAnExample_string' => 'This-Is-An-Example-String'
#
@@ -276,11 +283,11 @@
def train_case!(preserve_prefixed_underscores: true)
set_self_value self.train_case preserve_prefixed_underscores: preserve_prefixed_underscores
end
- # Checks if the string is train case
+ # Check if the string is train case
#
# @param [Boolean] allow_prefixed_underscores
# @return [Boolean]
def train_case?(allow_prefixed_underscores: true)
LuckyCase.train_case? self, allow_prefixed_underscores: allow_prefixed_underscores
@@ -288,11 +295,11 @@
#----------------------------------------------------------------------------------------------------
# WORD CASE
#----------------------------------------------------------------------------------------------------
- # Converts the given string from any case
+ # Convert the given string from any case
# into word case
#
# @example conversion
# 'this-isAnExample_string' => 'this is an example string'
#
@@ -304,19 +311,19 @@
def word_case!(preserve_prefixed_underscores: true)
set_self_value self.word_case preserve_prefixed_underscores: preserve_prefixed_underscores
end
- # Checks if the string is word case
+ # Check if the string is word case
#
# @param [Boolean] allow_prefixed_underscores
# @return [Boolean]
def word_case?(allow_prefixed_underscores: true)
LuckyCase.word_case? self, allow_prefixed_underscores: allow_prefixed_underscores
end
- # Converts the given string from any case
+ # Convert the given string from any case
# into upper word case
#
# @example conversion
# 'this-isAnExample_string' => 'THIS IS AN EXAMPLE STRING'
#
@@ -328,19 +335,19 @@
def upper_word_case!(preserve_prefixed_underscores: true)
set_self_value self.upper_word_case preserve_prefixed_underscores: preserve_prefixed_underscores
end
- # Checks if the string is upper word case
+ # Check if the string is upper word case
#
# @param [Boolean] allow_prefixed_underscores
# @return [Boolean]
def upper_word_case?(allow_prefixed_underscores: true)
LuckyCase.upper_word_case? self, allow_prefixed_underscores: allow_prefixed_underscores
end
- # Converts the given string from any case
+ # Convert the given string from any case
# into capital word case
#
# @example conversion
# 'this-isAnExample_string' => 'This Is An Example String'
#
@@ -352,11 +359,11 @@
def capital_word_case!(preserve_prefixed_underscores: true)
set_self_value self.capital_word_case preserve_prefixed_underscores: preserve_prefixed_underscores
end
- # Checks if the string is capital word case
+ # Check if the string is capital word case
#
# @param [Boolean] allow_prefixed_underscores
# @return [Boolean]
def capital_word_case?(allow_prefixed_underscores: true)
LuckyCase.capital_word_case? self, allow_prefixed_underscores: allow_prefixed_underscores
@@ -364,11 +371,11 @@
#----------------------------------------------------------------------------------------------------
# SENTENCE CASE
#----------------------------------------------------------------------------------------------------
- # Converts the given string from any case
+ # Convert the given string from any case
# into sentence case
#
# @example conversion
# 'this-isAnExample_string' => 'This is an example string'
#
@@ -380,11 +387,11 @@
def sentence_case!(preserve_prefixed_underscores: true)
set_self_value self.sentence_case preserve_prefixed_underscores: preserve_prefixed_underscores
end
- # Checks if the string is sentence case
+ # Check if the string is sentence case
#
# @param [Boolean] allow_prefixed_underscores
# @return [Boolean]
def sentence_case?(allow_prefixed_underscores: true)
LuckyCase.sentence_case? self, allow_prefixed_underscores: allow_prefixed_underscores
@@ -392,19 +399,19 @@
#----------------------------------------------------------------------------------------------------
# CAPITALIZE
#----------------------------------------------------------------------------------------------------
- # Converts the first character to capital
+ # Convert the first character to capital
#
# @param [Boolean] skip_prefixed_underscores
# @return [String]
def capital(skip_prefixed_underscores: false)
LuckyCase.capitalize self, skip_prefixed_underscores: skip_prefixed_underscores
end
- # Converts the first character to capital
+ # Convert the first character to capital
#
# @param [Boolean] skip_prefixed_underscores
# @return [String]
def capitalize(skip_prefixed_underscores: false)
self.capital skip_prefixed_underscores: skip_prefixed_underscores
@@ -416,19 +423,19 @@
def capitalize!(skip_prefixed_underscores: false)
self.capital! skip_prefixed_underscores: skip_prefixed_underscores
end
- # Checks if the strings first character is a capital letter
+ # Check if the strings first character is a capital letter
#
# @param [Boolean] skip_prefixed_underscores
# @return [Boolean]
def capital?(skip_prefixed_underscores: false)
LuckyCase.capital? self, skip_prefixed_underscores: skip_prefixed_underscores
end
- # Checks if the strings first character is a capital letter
+ # Check if the strings first character is a capital letter
#
# @param [Boolean] skip_prefixed_underscores
# @return [Boolean]
def capitalized?(skip_prefixed_underscores: false)
self.capital? skip_prefixed_underscores: skip_prefixed_underscores
@@ -436,11 +443,11 @@
#----------------------------------------------------------------------------------------------------
# MIXED CASE
#----------------------------------------------------------------------------------------------------
- # Converts the given string from any case
+ # Convert the given string from any case
# into mixed case
#
# @example conversion
# 'this-isAnExample_string' => 'This-Is_anExample-string'
#
@@ -452,11 +459,11 @@
def mixed_case!(preserve_prefixed_underscores: true)
set_self_value self.mixed_case preserve_prefixed_underscores: preserve_prefixed_underscores
end
- # Checks if the string is a valid mixed case (without special characters!)
+ # Check if the string is a valid mixed case (without special characters!)
#
# @return [Boolean]
def mixed_case?()
LuckyCase.mixed_case? self
end
@@ -489,10 +496,10 @@
#----------------------------------------------------------------------------------------------------
# CONSTANTIZE
#----------------------------------------------------------------------------------------------------
- # Converts the string from any case
+ # Convert the string from any case
# into pascal case and casts it into a constant
#
# @example conversion
# 'this-isAnExample_string' => ThisIsAnExampleString
# 'this/is_an/example_path' => This::IsAn::ExamplePath
\ No newline at end of file