Class: Staticpress::Plugins::Menu::MenuItem
- Inherits:
-
Object
- Object
- Staticpress::Plugins::Menu::MenuItem
- Defined in:
- lib/staticpress/plugins/menu.rb
Instance Attribute Summary collapse
-
#position ⇒ Object
readonly
Returns the value of attribute position.
-
#sub_items ⇒ Object
readonly
Returns the value of attribute sub_items.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#url_path ⇒ Object
readonly
Returns the value of attribute url_path.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(position, text, url_path, sub_items = []) ⇒ MenuItem
constructor
A new instance of MenuItem.
Constructor Details
#initialize(position, text, url_path, sub_items = []) ⇒ MenuItem
Returns a new instance of MenuItem.
62 63 64 65 66 67 |
# File 'lib/staticpress/plugins/menu.rb', line 62 def initialize(position, text, url_path, sub_items = []) @position = position.to_i @text = text @url_path = url_path @sub_items = sub_items end |
Instance Attribute Details
#position ⇒ Object (readonly)
Returns the value of attribute position.
60 61 62 |
# File 'lib/staticpress/plugins/menu.rb', line 60 def position @position end |
#sub_items ⇒ Object (readonly)
Returns the value of attribute sub_items.
60 61 62 |
# File 'lib/staticpress/plugins/menu.rb', line 60 def sub_items @sub_items end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
60 61 62 |
# File 'lib/staticpress/plugins/menu.rb', line 60 def text @text end |
#url_path ⇒ Object (readonly)
Returns the value of attribute url_path.
60 61 62 |
# File 'lib/staticpress/plugins/menu.rb', line 60 def url_path @url_path end |
Instance Method Details
#<=>(other) ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'lib/staticpress/plugins/menu.rb', line 69 def <=>(other) reply = case when (position < 0) && (other.position < 0) then other.position.abs <=> position.abs when (position < 0) || (other.position < 0) then other.position <=> position else position <=> other.position end reply.zero? ? (text <=> other.text) : reply end |