Class: Stamina::Gui::Examples::Category

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/stamina-gui/stamina/gui/examples.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(folder) ⇒ Category

Returns a new instance of Category.



22
23
24
# File 'lib/stamina-gui/stamina/gui/examples.rb', line 22

def initialize(folder)
  @folder = folder
end

Instance Attribute Details

#folderObject (readonly)

Returns the value of attribute folder.



20
21
22
# File 'lib/stamina-gui/stamina/gui/examples.rb', line 20

def folder
  @folder
end

Instance Method Details

#eachObject



35
36
37
38
39
# File 'lib/stamina-gui/stamina/gui/examples.rb', line 35

def each
  Dir[File.join(folder, "*.rb")].sort.each do |file|
    yield(Example.new(file))
  end
end

#labelObject



30
31
32
33
# File 'lib/stamina-gui/stamina/gui/examples.rb', line 30

def label
  File.basename(folder) =~ /^\d+-(.*)$/
  $1.gsub(/-/, " ").capitalize
end

#urlObject



26
27
28
# File 'lib/stamina-gui/stamina/gui/examples.rb', line 26

def url
  File.basename(folder)
end