Class: Cartoonist::Admin::Tab
- Inherits:
-
Object
- Object
- Cartoonist::Admin::Tab
- Defined in:
- lib/cartoonist.rb
Constant Summary collapse
- @@all =
{}
- @@cached_order =
[]
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(key, options) ⇒ Tab
constructor
A new instance of Tab.
Constructor Details
#initialize(key, options) ⇒ Tab
Returns a new instance of Tab.
18 19 20 21 22 |
# File 'lib/cartoonist.rb', line 18 def initialize(key, ) @key = key @url = [:url] @order = [:order] end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
13 14 15 |
# File 'lib/cartoonist.rb', line 13 def key @key end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
13 14 15 |
# File 'lib/cartoonist.rb', line 13 def order @order end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
13 14 15 |
# File 'lib/cartoonist.rb', line 13 def url @url end |
Class Method Details
.[](key) ⇒ Object
29 30 31 |
# File 'lib/cartoonist.rb', line 29 def [](key) @@all[key].url end |
.add(key, options) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/cartoonist.rb', line 33 def add(key, ) @@all[key] = Cartoonist::Admin::Tab.new key, @@cached_order = @@all.values.sort do |a, b| if a.order && b.order a.order <=> b.order elsif a.order && !b.order -1 elsif b.order && !a.order 1 else a.key <=> b.key end end.map &:key end |
.all ⇒ Object
25 26 27 |
# File 'lib/cartoonist.rb', line 25 def all @@cached_order end |