Class: AlohaAnalyzer::User
- Inherits:
-
Object
- Object
- AlohaAnalyzer::User
- Defined in:
- lib/aloha_analyzer/user.rb
Instance Attribute Summary collapse
-
#analysis ⇒ Object
readonly
Returns the value of attribute analysis.
-
#language ⇒ Object
readonly
Returns the value of attribute language.
Instance Method Summary collapse
- #analyze(users) ⇒ Object
- #boilerplate ⇒ Object
-
#initialize(options) ⇒ User
constructor
A new instance of User.
Constructor Details
#initialize(options) ⇒ User
Returns a new instance of User.
6 7 8 9 10 |
# File 'lib/aloha_analyzer/user.rb', line 6 def initialize() @language = clean_language(['language'].downcase) @analysis = (['analysis'] || boilerplate).clone @options = end |
Instance Attribute Details
#analysis ⇒ Object (readonly)
Returns the value of attribute analysis.
4 5 6 |
# File 'lib/aloha_analyzer/user.rb', line 4 def analysis @analysis end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
4 5 6 |
# File 'lib/aloha_analyzer/user.rb', line 4 def language @language end |
Instance Method Details
#analyze(users) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/aloha_analyzer/user.rb', line 12 def analyze(users) clean_users(users).each do |user| if user['lang'] == @language add_account_language_user(user) @analysis['account_language']['count'] += 1 else add_foreign_language_user(user) @analysis['foreign_languages_count'] += 1 end @analysis['count'] += 1 end @analysis end |
#boilerplate ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/aloha_analyzer/user.rb', line 26 def boilerplate { 'account_language' => { 'count' => 0, 'language' => Language.find_by_abbreviation(@language), 'users' => [] }, 'foreign_languages_count' => 0, 'count' => 0, 'foreign_languages' => {} } end |