Class: Fb::Metric

Inherits:
Object
  • Object
show all
Defined in:
lib/fb/metric.rb

Overview

Fb::Metric reprensents a Facebook page’s metric. For a list of all available metrics, refer to: Provides methods to read name, description, and value.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Metric

Returns a new instance of Metric.

Parameters:

  • options (Hash) (defaults to: {})

    the options to initialize an instance of Fb::Metric.

  • [String] (Hash)

    a customizable set of options

  • [Integer] (Hash)

    a customizable set of options



24
25
26
27
28
# File 'lib/fb/metric.rb', line 24

def initialize(options = {})
  @name = options["name"]
  @description = options["description"]
  @value = options["values"].first["value"]
end

Instance Attribute Details

#descriptionString (readonly)

Returns a description for the metric.

Returns:

  • (String)

    a description for the metric.



14
15
16
# File 'lib/fb/metric.rb', line 14

def description
  @description
end

#nameString (readonly)

Returns the name of the metric (e.g. page_fans).

Returns:

  • (String)

    the name of the metric (e.g. page_fans).



11
12
13
# File 'lib/fb/metric.rb', line 11

def name
  @name
end

#valueInteger (readonly)

Returns the value of the metric when last requested.

Returns:

  • (Integer)

    the value of the metric when last requested.



17
18
19
# File 'lib/fb/metric.rb', line 17

def value
  @value
end

Instance Method Details

#to_sString

Returns the representation of the metric.

Returns:

  • (String)

    the representation of the metric.



31
32
33
# File 'lib/fb/metric.rb', line 31

def to_s
  "#<#{self.class.name} name=#{@name}, description=#{@description}, value=#{@value}>"
end