class Typography
Attributes
escape[R]
result[R]
word[R]
Public Class Methods
new(word, escape, result)
click to toggle source
# File lib/typography.rb, line 6 def initialize(word, escape, result) @word = word @escape = escape @result = result end
Public Instance Methods
call()
click to toggle source
# File lib/typography.rb, line 12 def call analyze_string end
Private Instance Methods
add_value_to_result(capitalized, upcased, value)
click to toggle source
# File lib/typography.rb, line 50 def add_value_to_result(capitalized, upcased, value) if check_sensitive(capitalized, upcased) == false result << value else capitalize_or_upcase(capitalized, upcased, value) end end
analyze_string()
click to toggle source
# File lib/typography.rb, line 18 def analyze_string check_word_length if escape.map(&:downcase).include?(word.downcase) result.push(word) elsif Config::TRANSLATION.has_key?(word.downcase) get_value(word, @capitalized, @upcased, result) else result.push(word) end end
capitalize_or_upcase(capitalized, upcased, value)
click to toggle source
# File lib/typography.rb, line 63 def capitalize_or_upcase(capitalized, upcased, value) result << value.capitalize if capitalized result << value.upcase if upcased result end
capitalized?(word)
click to toggle source
# File lib/typography.rb, line 37 def capitalized? word word == word.capitalize end
check_sensitive(capitalized, upcased)
click to toggle source
# File lib/typography.rb, line 58 def check_sensitive(capitalized, upcased) return if (capitalized || upcased) false end
check_word_length()
click to toggle source
# File lib/typography.rb, line 29 def check_word_length if word.length == 1 @capitalized = capitalized? word else @capitalized, @upcased = capitalized?(word), upcased?(word) end end
get_value(word, capitalized, upcased, result)
click to toggle source
# File lib/typography.rb, line 45 def get_value(word, capitalized, upcased, result) value = Config::TRANSLATION.fetch(word.downcase) add_value_to_result(capitalized, upcased, value) end
upcased?(word)
click to toggle source
# File lib/typography.rb, line 41 def upcased? word word == word.upcase end