Sha256: f0841b4f3c9e0b40046be869d9a35b0d4f7a9e1cac4b95fdf42d6ff0408c69c0

Contents?: true

Size: 652 Bytes

Versions: 3

Compression:

Stored size: 652 Bytes

Contents

class SoftwareBinder::Category
  attr_accessor :name, :slug

  @@all = []

  def initialize
    self.save
  end

  def self.all
    @@all
  end

  def self.reset
    @@all.clear
  end

  def save
    @@all << self
  end

  def self.find_by_keyword(keyword)
    self.all.select do |category|
      category.name.downcase.include?(keyword.downcase)
    end
  end

  def self.find_by_alphabet(alphabet)
    if alphabet === "#"
      self.all.select do |category|
        category.name.chr.to_i.between?(1,9) == true
      end
    else
      self.all.select do |category|
        category.name.downcase.chr == alphabet.downcase
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
software_binder-0.1.3 lib/software_binder/category.rb
software_binder-0.1.2 lib/software_binder/category.rb
software_binder-0.1.1 lib/software_binder/category.rb