Class: Nomen::Relation

Inherits:
Array
  • Object
show all
Defined in:
lib/nomen/relation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nomenclature, *args) ⇒ Relation

Returns a new instance of Relation.


7
8
9
10
# File 'lib/nomen/relation.rb', line 7

def initialize(nomenclature, *args)
  super(*args)
  @nomenclature = nomenclature
end

Instance Attribute Details

#nomenclatureObject (readonly)

Returns the value of attribute nomenclature


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

def nomenclature
  @nomenclature
end

Instance Method Details

#selection(sorted = true) ⇒ Object


18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/nomen/relation.rb', line 18

def selection(sorted = true)
  unit_selec = collect do |item|
    [item.human_name, item.name.to_s]
  end
  if sorted
    unit_selec.sort! do |a, b|
      a.first.lower_ascii <=> b.first.lower_ascii
    end
  end

  unit_selec
end