class ShopifyApp

Attributes

app_reviews[RW]
category[RW]
description[RW]
developer_contact[RW]
developer_name[RW]
developer_url[RW]
name[RW]
overall_rating[RW]
url[RW]

Public Class Methods

all() click to toggle source
# File lib/shopify_app_reviews/shopify_app.rb, line 22
def self.all
  @@all
end
create_from_collection(app_array) click to toggle source
# File lib/shopify_app_reviews/shopify_app.rb, line 69
def self.create_from_collection(app_array)
  app_array.each do |app_info|
    self.create(app_info)
  end
end
new(attributes) click to toggle source
# File lib/shopify_app_reviews/shopify_app.rb, line 10
def initialize(attributes)
  @name = attributes[:name]
  @url = attributes[:url]
  @category = attributes[:category]
  @developer_name = attributes[:developer_name]
  @developer_url = attributes[:developer_url]
  @description = attributes[:description] if attributes[:description]
  @overall_rating = attributes[:overall_rating] if attributes[:overall_rating]
  @developer_contact = attributes[:developer_contact] if attributes[:developer_contact]
  @app_reviews = []
end

Public Instance Methods

overall_sentiment() click to toggle source
# File lib/shopify_app_reviews/shopify_app.rb, line 55
def overall_sentiment
  set_sentiment(self.overall_rating)
end
set_sentiment(rating_type) click to toggle source
# File lib/shopify_app_reviews/shopify_app.rb, line 38
def set_sentiment(rating_type)
  sentiment = "Unknown"
  if rating_type.is_a?(String)
    rating = rating_type.split(" ").first
    rating = rating.to_f
  else
    rating = rating_type
  end
  sentiment = "terrible (#{rating}/5)".colorize(:red) if rating.between?(0.00,0.999)
  sentiment = "really bad (#{rating}/5)".colorize(:red) if rating.between?(1.00,1.999)
  sentiment = "OK at best (#{rating}/5)".colorize(:yellow) if rating.between?(2.00,2.999)
  sentiment = "good (#{rating}/5)".colorize(:yellow) if rating.between?(3.00,3.999)
  sentiment = "great (#{rating}/5)".colorize(:cyan) if rating.between?(4.00,4.499)
  sentiment = "excellent (#{rating}/5)".colorize(:cyan) if rating.between?(4.50,5.00)
  sentiment
end
total_review_count() click to toggle source
# File lib/shopify_app_reviews/shopify_app.rb, line 34
def total_review_count
  app_reviews.count
end