Sha256: fefd499006ef75a97e599dfaa3e2c5e59e8e6fed8708bf07ccd4cb95ac26244a
Contents?: true
Size: 622 Bytes
Versions: 46
Compression:
Stored size: 622 Bytes
Contents
class Blog::Category attr_reader :name, :plural, :slug, :color attr_accessor :blogposts def initialize(attributes) # attributes.each {|k, v| self.instance_variable_set("@#{k}", v)} @name = attributes['name'] @plural = attributes['plural'] @slug = attributes['slug'] @color = attributes['color'] @blogposts = [] end def build_n_blogposts_by_category(blogposts_json, num = 0) bp = blogposts_json.select { |b| b['category']['slug'].downcase == @slug.downcase } bp = bp.first(num) if num.positive? @blogposts = bp.map { |b| Blog::Blogpost.new b } self end end
Version data entries
46 entries across 46 versions & 1 rubygems