Class: WOR::Collection
- Inherits:
-
Object
- Object
- WOR::Collection
- Defined in:
- lib/wor/collection.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
- .get_folder_name(params) ⇒ Object
- .get_folder_name_by_path(params) ⇒ Object
- .get_folder_url(params) ⇒ Object
Instance Method Summary collapse
-
#initialize(collection_name) ⇒ Collection
constructor
A new instance of Collection.
- #items ⇒ Object
Constructor Details
#initialize(collection_name) ⇒ Collection
Returns a new instance of Collection.
55 56 57 |
# File 'lib/wor/collection.rb', line 55 def initialize collection_name @name = collection_name end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/wor/collection.rb', line 3 def name @name end |
Class Method Details
.get_folder_name(params) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/wor/collection.rb', line 7 def get_folder_name params if (!WOR::Configuration::USE_LOCALIZATION) return params[:collection_name] end locale_info = WOR::Localization.read_locale_file(params[:locale]) if (locale_info.nil?) return params[:collection_name] end collection_name = params[:collection_name] locale_info['paths'].each do | key, value | if (value == params[:collection_name].to_s) collection_name = key end end return collection_name end |
.get_folder_name_by_path(params) ⇒ Object
29 30 31 32 |
# File 'lib/wor/collection.rb', line 29 def get_folder_name_by_path(params) original_collection_name = WOR::Helpers.get_parent_directory_name params[:path] return get_folder_name(locale: params[:locale], collection_name: original_collection_name) end |
.get_folder_url(params) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/wor/collection.rb', line 34 def get_folder_url(params) if (!WOR::Configuration::USE_LOCALIZATION) return params[:collection_name] end locale_info = WOR::Localization.read_locale_file(params[:locale]) if (locale_info.nil?) return params[:collection_name] end locale_info['paths'].each do | key, value | if (key == params[:collection_name].to_s) return value end end return params[:collection_name] end |
Instance Method Details
#items ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/wor/collection.rb', line 59 def items files = Dir.glob("#{Rails.root}/content/#{self.name.downcase}/*") @items = Array.new files.each do | file | item = CollectionItem.new file @items << item end return @items end |