Sha256: a11fa0cc323b381b273a9df836f28d3977001c900db115740d98384d8a25ab96

Contents?: true

Size: 914 Bytes

Versions: 2

Compression:

Stored size: 914 Bytes

Contents

module Smite
  class Item < Smite::Object

    def initialize(data)
      super(data)
      effects              = @data.delete('item_description')
      @data['description'] = effects.delete('Description')
      @data['effects']     = effects['Menuitems'].map do |eff|
        ItemEffect.new(device_name, eff)
      end
    end

    def active?
      type == 'Active'
    end

    def consumable?
      type == 'Consumable'
    end

    def item?
      type == 'Item'
    end

    def starter?
      starting_item
    end

    def name
      device_name
    end

    def physical?
      @physical ||= !effects.map(&:attribute).any? do |eff|
        eff =~ /magic(al)?_(power|pen)/
      end
    end

    def magic?
      @magic ||= !effects.map(&:attribute).any? do |eff|
        eff =~ /physical_(power|pen)/
      end
    end

    def inspect
      "#<Smite::Item #{item_id} '#{device_name}'>"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
smite_ruby-1.4.6 lib/smite/item.rb
smite_ruby-1.4.5 lib/smite/item.rb