Class: Trestle::Navigation::Group
- Inherits:
-
Object
- Object
- Trestle::Navigation::Group
- Defined in:
- lib/trestle/navigation/group.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
- #id ⇒ Object
-
#initialize(name, options = {}) ⇒ Group
constructor
A new instance of Group.
- #label ⇒ Object
- #priority ⇒ Object
Constructor Details
#initialize(name, options = {}) ⇒ Group
Returns a new instance of Group.
6 7 8 9 |
# File 'lib/trestle/navigation/group.rb', line 6 def initialize(name, ={}) @name = name @options = end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/trestle/navigation/group.rb', line 4 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/trestle/navigation/group.rb', line 4 def @options end |
Instance Method Details
#<=>(other) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/trestle/navigation/group.rb', line 20 def <=>(other) case other when Group priority <=> other.priority when NullGroup 1 end end |
#==(other) ⇒ Object Also known as: eql?
11 12 13 |
# File 'lib/trestle/navigation/group.rb', line 11 def ==(other) other.is_a?(self.class) && name == other.name end |
#hash ⇒ Object
16 17 18 |
# File 'lib/trestle/navigation/group.rb', line 16 def hash name.hash end |
#id ⇒ Object
44 45 46 |
# File 'lib/trestle/navigation/group.rb', line 44 def id name.to_s.parameterize end |
#label ⇒ Object
40 41 42 |
# File 'lib/trestle/navigation/group.rb', line 40 def label I18n.t("admin.navigation.groups.#{name}", default: name.to_s.titlecase) end |
#priority ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/trestle/navigation/group.rb', line 29 def priority case [:priority] when :first -Float::INFINITY when :last Float::INFINITY else [:priority] || 0 end end |