Class: WolframAlpha::Pod
- Inherits:
-
Object
- Object
- WolframAlpha::Pod
- Defined in:
- library/wolfram-alpha/pod.rb
Overview
A wrapper for the pod element.
Instance Attribute Summary collapse
-
#subpods ⇒ Array<Subpod>
readonly
An list of sub-pods in this pod.
Instance Method Summary collapse
-
#id ⇒ String
Returns the pod id.
-
#initialize(element) ⇒ Pod
constructor
Construct a new pod with an assigned element, then extract all subpods from it.
-
#inspect ⇒ Object
Inspect the pod.
-
#position ⇒ Fixnum
Returns the pod position.
-
#scanner ⇒ String
Returns the pod scanner.
-
#subpods? ⇒ Boolean
Returns whether the pod has any subpods.
-
#title ⇒ String
Returns the pod title.
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
#subpods ⇒ Array<Subpod> (readonly)
Returns 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
#id ⇒ String
Returns the pod id.
24 25 26 |
# File 'library/wolfram-alpha/pod.rb', line 24 def id @element["id"] end |
#inspect ⇒ Object
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 |
#position ⇒ Fixnum
Returns the pod position.
45 46 47 |
# File 'library/wolfram-alpha/pod.rb', line 45 def position @element["position"].to_i end |
#scanner ⇒ String
Returns 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.
17 18 19 |
# File 'library/wolfram-alpha/pod.rb', line 17 def subpods? @subpods and @subpods.any? end |
#title ⇒ String
Returns the pod title.
31 32 33 |
# File 'library/wolfram-alpha/pod.rb', line 31 def title @element["title"] end |