Class: Tml::Tokens::XMessage::Choice

Inherits:
Data
  • Object
show all
Defined in:
lib/tml/tokens/x_message/choice.rb

Overview

Choice Token

0 tagged himself/herself in 1,choice,singular1,choice,singular#{1,number 2,map,photo2,map,photo#photo|video2,map,photo#photo|video#video|plural#1,number 2,map,photo2,map,photo#photos|video2,map,photo#photos|video#videos}.

Instance Attribute Summary collapse

Attributes inherited from Data

#case_keys, #context_keys, #full_name, #label, #short_name

Instance Method Summary collapse

Methods inherited from Data

#apply_case, #apply_language_cases, #context_for_language, #decorate, #decoration_name, #error, expression, #key, #language_cases_enabled?, #name, #name_for_case_keys, parse, #parse_elements, #sanitize, #sanitized_name, #substitute, #to_s, #token_object, token_object, #token_value, #token_value_from_array_param, #token_value_from_hash_param, #token_values_from_array

Constructor Details

#initialize(label, opts) ⇒ Choice

Returns a new instance of Choice.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/tml/tokens/x_message/choice.rb', line 45

def initialize(label, opts)
  @label = label
  @short_name = opts[:index]
  @full_name = "{#{@short_name}}"
  @rule_keys = opts[:styles].collect{|style| style[:key]}
  @case_keys = []
  @context_keys = []
  if @rule_keys.include?('singular') or @rule_keys.include?('plural')
    @context_keys = ['number']
  elsif @rule_keys.include?('male') or @rule_keys.include?('female')
    @context_keys = ['gender']
  elsif @rule_keys.include?('past') or @rule_keys.include?('present') or @rule_keys.include?('future')
    @context_keys = ['date']
  end
end

Instance Attribute Details

#rule_keysObject

Returns the value of attribute rule_keys.



43
44
45
# File 'lib/tml/tokens/x_message/choice.rb', line 43

def rule_keys
  @rule_keys
end