Class: Cartoonist::Navigation::Link
- Inherits:
-
Object
- Object
- Cartoonist::Navigation::Link
- Defined in:
- lib/cartoonist.rb
Constant Summary collapse
- @@all =
[]
- @@cached_order =
[]
Instance Attribute Summary collapse
-
#class ⇒ Object
readonly
Returns the value of attribute class.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#preview_url ⇒ Object
readonly
Returns the value of attribute preview_url.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options) ⇒ Link
constructor
A new instance of Link.
- #url(preview = false) ⇒ Object
Constructor Details
#initialize(options) ⇒ Link
Returns a new instance of Link.
170 171 172 173 174 175 176 177 |
# File 'lib/cartoonist.rb', line 170 def initialize() @url = [:url] @preview_url = [:preview_url] @class = [:class] @label = [:label] @title = [:title] @order = [:order] end |
Instance Attribute Details
#class ⇒ Object (readonly)
Returns the value of attribute class.
165 166 167 |
# File 'lib/cartoonist.rb', line 165 def class @class end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
165 166 167 |
# File 'lib/cartoonist.rb', line 165 def label @label end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
165 166 167 |
# File 'lib/cartoonist.rb', line 165 def order @order end |
#preview_url ⇒ Object (readonly)
Returns the value of attribute preview_url.
165 166 167 |
# File 'lib/cartoonist.rb', line 165 def preview_url @preview_url end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
165 166 167 |
# File 'lib/cartoonist.rb', line 165 def title @title end |
Class Method Details
.add(options) ⇒ Object
198 199 200 201 |
# File 'lib/cartoonist.rb', line 198 def add() @@all << Cartoonist::Navigation::Link.new() @@cached_order = @@all.sort { |x, y| x.order <=> y.order } end |
.all ⇒ Object
194 195 196 |
# File 'lib/cartoonist.rb', line 194 def all @@cached_order end |
Instance Method Details
#url(preview = false) ⇒ Object
179 180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/cartoonist.rb', line 179 def url(preview = false) if preview && @preview_url result = @preview_url else result = @url end if result.kind_of? Proc result.call else result end end |