Class: WolframAlpha::Pod

Inherits:
Object
  • Object
show all
Defined in:
library/wolfram-alpha/pod.rb

Overview

A wrapper for the pod element.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(element) ⇒ Pod

Construct a new pod with an assigned element, then extract all subpods from it.



10
11
12
13
14
# File 'library/wolfram-alpha/pod.rb', line 10

def initialize element
  @element = element

  extract_subpods
end

Instance Attribute Details

#subpodsArray<Subpod> (readonly)

Returns an list of sub-pods in this pod.

Returns:

  • (Array<Subpod>)

    an list of sub-pods in this pod.



7
8
9
# File 'library/wolfram-alpha/pod.rb', line 7

def subpods
  @subpods
end

Instance Method Details

#idString

Returns the pod id.

Returns:

  • (String)

    the pod id.



24
25
26
# File 'library/wolfram-alpha/pod.rb', line 24

def id
  @element["id"]
end

#inspectObject

Inspect the pod.



50
51
52
# File 'library/wolfram-alpha/pod.rb', line 50

def inspect
  %{#<#{self.class.name} id: #{id.inspect} title: #{title.inspect} scanner: #{scanner.inspect} position: #{position.inspect} @subpods=#{@subpods.inspect}>}
end

#positionFixnum

Returns the pod position.

Returns:

  • (Fixnum)

    the pod position.



45
46
47
# File 'library/wolfram-alpha/pod.rb', line 45

def position
  @element["position"].to_i
end

#scannerString

Returns the pod scanner.

Returns:

  • (String)

    the pod scanner.



38
39
40
# File 'library/wolfram-alpha/pod.rb', line 38

def scanner
  @element["scanner"]
end

#subpods?Boolean

Returns whether the pod has any subpods.

Returns:

  • (Boolean)


17
18
19
# File 'library/wolfram-alpha/pod.rb', line 17

def subpods?
  @subpods and @subpods.any?
end

#titleString

Returns the pod title.

Returns:

  • (String)

    the pod title.



31
32
33
# File 'library/wolfram-alpha/pod.rb', line 31

def title
  @element["title"]
end