Module: Humanizer

Included in:
HumanizerHelper
Defined in:
lib/humanizer.rb,
lib/humanizer/version.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

VERSION =
"2.7.1"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#humanizer_answerObject

Returns the value of attribute humanizer_answer.



7
8
9
# File 'lib/humanizer.rb', line 7

def humanizer_answer
  @humanizer_answer
end

#humanizer_question_idObject



14
15
16
# File 'lib/humanizer.rb', line 14

def humanizer_question_id
  (@humanizer_question_id ||= random_humanizer_question_id).to_i
end

Class Method Details

.included(base) ⇒ Object



3
4
5
# File 'lib/humanizer.rb', line 3

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#change_humanizer_question(current = nil) ⇒ Object



18
19
20
21
22
# File 'lib/humanizer.rb', line 18

def change_humanizer_question(current=nil)
  @humanizer_question_ids = nil if humanizer_question_ids.compact.count == 1
  humanizer_question_ids.delete(current) if current
  @humanizer_question_id = random_humanizer_question_id
end

#humanizer_correct_answer?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/humanizer.rb', line 24

def humanizer_correct_answer?
  humanizer_answer && humanizer_answers_for_id(humanizer_question_id).include?(humanizer_answer.mb_chars.downcase.strip)
end

#humanizer_questionObject



10
11
12
# File 'lib/humanizer.rb', line 10

def humanizer_question
  humanizer_questions[humanizer_question_id.to_i]["question"]
end