Sha256: a751b314cfa8c4ece0ec6f3a456d70da6a247993b81ad3da424e1db06462a95a
Contents?: true
Size: 1.23 KB
Versions: 3
Compression:
Stored size: 1.23 KB
Contents
require 'ostruct' module Getapp module Capterra # == Getapp::Capterra::Product Class # # Responsible for transforming Capterra formatted product # into common Getapp product format. # class Product attr_reader :product, :verbose # == Getapp::Capterra::Product::PRODUCT_KEYS_MAPPING Constant # # Hold key mappings for Capterra Product to Getapp Product # PRODUCT_KEYS_MAPPING = { name: :Name, tags: :Categories, twitter: :Twitter }.freeze # == Getapp::Capterra::Product initialize Method # # @param [Hash<String: String>], Boolean # @return Getapp::Capterra::Product instance. # def initialize(product, verbose = false) @product = product.transform_keys(&:to_sym) @verbose = verbose end # == Getapp::Capterra::Product get Method # # Transform keys from Capterra::Product to Getapp Product # # @param [String] # @return [OpenStruct<Key=Value>] # #<OpenStruct Name="GitHub", Categories="Bugs & Issue Tracking,Development Tools", Twitter="github"> def get OpenStruct.new(PRODUCT_KEYS_MAPPING.map { |k, v| [v, product[k]] }.to_h) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
getapp-0.1.2 | lib/getapp/capterra/product.rb |
getapp-0.1.1 | lib/getapp/capterra/product.rb |
getapp-0.1.0 | lib/getapp/capterra/product.rb |