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?)
- #collapse? ⇒ Boolean
- #hash ⇒ Object
- #id ⇒ Object
-
#initialize(name, options = {}) ⇒ Group
constructor
A new instance of Group.
- #label ⇒ Object
- #merge(other) ⇒ Object
- #priority ⇒ Object
Constructor Details
#initialize(name, options = {}) ⇒ Group
Returns a new instance of Group.
6 7 8 |
# File 'lib/trestle/navigation/group.rb', line 6 def initialize(name, ={}) @name, @options = name.to_s, 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
19 20 21 22 23 24 25 26 |
# File 'lib/trestle/navigation/group.rb', line 19 def <=>(other) case other when Group priority <=> other.priority when NullGroup 1 end end |
#==(other) ⇒ Object Also known as: eql?
10 11 12 |
# File 'lib/trestle/navigation/group.rb', line 10 def ==(other) other.is_a?(self.class) && name == other.name end |
#collapse? ⇒ Boolean
43 44 45 |
# File 'lib/trestle/navigation/group.rb', line 43 def collapse? [:collapse] end |
#hash ⇒ Object
15 16 17 |
# File 'lib/trestle/navigation/group.rb', line 15 def hash name.hash end |
#id ⇒ Object
51 52 53 |
# File 'lib/trestle/navigation/group.rb', line 51 def id name.to_s.parameterize end |
#label ⇒ Object
47 48 49 |
# File 'lib/trestle/navigation/group.rb', line 47 def label I18n.t("admin.navigation.groups.#{name}", default: name.to_s.titlecase) end |
#merge(other) ⇒ Object
28 29 30 |
# File 'lib/trestle/navigation/group.rb', line 28 def merge(other) self.class.new(name, .merge(other.)) end |
#priority ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/trestle/navigation/group.rb', line 32 def priority case [:priority] when :first -Float::INFINITY when :last Float::INFINITY else [:priority] || 0 end end |