Class: MDEXClient::MData::Dimension

Inherits:
Node
  • Object
show all
Defined in:
lib/mdex_client/mdata/dimension.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#element

Instance Method Summary collapse

Methods inherited from Node

#css, #dimension_value_state_list, #initialize, #property_list, #record_list, #xpath

Constructor Details

This class inherits a constructor from MDEXClient::MData::Node

Instance Attribute Details

#group_nameObject

Returns the value of attribute group_name.



7
8
9
# File 'lib/mdex_client/mdata/dimension.rb', line 7

def group_name
  @group_name
end

#idObject

Returns the value of attribute id.



7
8
9
# File 'lib/mdex_client/mdata/dimension.rb', line 7

def id
  @id
end

#implicit_value_idsObject

Returns the value of attribute implicit_value_ids.



7
8
9
# File 'lib/mdex_client/mdata/dimension.rb', line 7

def implicit_value_ids
  @implicit_value_ids
end

#multi_selectObject

Returns the value of attribute multi_select.



7
8
9
# File 'lib/mdex_client/mdata/dimension.rb', line 7

def multi_select
  @multi_select
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/mdex_client/mdata/dimension.rb', line 7

def name
  @name
end

#parent_idObject

Returns the value of attribute parent_id.



7
8
9
# File 'lib/mdex_client/mdata/dimension.rb', line 7

def parent_id
  @parent_id
end

#refinementsObject

Returns the value of attribute refinements.



7
8
9
# File 'lib/mdex_client/mdata/dimension.rb', line 7

def refinements
  @refinements
end

#selected_value_idsObject

Returns the value of attribute selected_value_ids.



7
8
9
# File 'lib/mdex_client/mdata/dimension.rb', line 7

def selected_value_ids
  @selected_value_ids
end

#valuesObject

Returns the value of attribute values.



7
8
9
# File 'lib/mdex_client/mdata/dimension.rb', line 7

def values
  @values
end

Instance Method Details

#has_more_refinements?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/mdex_client/mdata/dimension.rb', line 42

def has_more_refinements?
  @has_more_refinements
end

#initialize_dimension_state!(element, dimension_values) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/mdex_client/mdata/dimension.rb', line 28

def initialize_dimension_state!(element, dimension_values)
  node = Node.new(element)
  refinement_list = node.xpath("mdata:Refinements").first
  if refinement_list
    @parent_id = refinement_list["ParentId"].to_i
    @has_more_refinements = (refinement_list["HasMore"] == "true")
    @is_refinable = (refinement_list["IsRefinable"] == "true")
  end
  
  @refinements = node.dimension_value_state_list("mdata:Refinements", dimension_values)      
  @selected_value_ids = node.dimension_value_state_list("mdata:SelectedDimensionValues", dimension_values)
  @implicit_value_ids = node.dimension_value_state_list("mdata:ImplicitDimensionValues", dimension_values)
end

#initialize_from_element!Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/mdex_client/mdata/dimension.rb', line 10

def initialize_from_element!
  @id = @element["Id"].to_i
  @name = @element["Name"]
  @multi_select = @element["MultiSelect"]
  @group_name = @element["GroupName"]
  
  @values = {}
  xpath("mdata:DimensionValue").each do |value|
    dv = DimensionValue.new(value)
    dv.dimension = self
    @values[dv.id] = dv
  end
  
  @refinements ||= []
  @selected_value_ids ||= []
  @implicit_value_ids ||= []
end

#refinable?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/mdex_client/mdata/dimension.rb', line 46

def refinable?
  @is_refinable
end