Class: WolframAlpha::Subpod

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

Instance Method Summary collapse

Constructor Details

#initialize(parent, element) ⇒ Subpod

Construct a new pod with an assigned element.



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

def initialize parent, element
  @parent = parent
  @element = element
end

Instance Method Details

#inspectObject

Inspect the subpod.



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

def inspect
  %{#<#{self.class.name} plaintext: #{plaintext.inspect}>}
end

#plaintextString

Returns the plaintext element as text.

Returns:

  • (String)

    the plain text.



19
20
21
# File 'library/wolfram-alpha/subpod.rb', line 19

def plaintext
  @plaintext ||= @element.at_css("plaintext").text
end

#plaintext?Boolean

Returns whether the subpod contains a plaintext element.

Returns:

  • (Boolean)


12
13
14
# File 'library/wolfram-alpha/subpod.rb', line 12

def plaintext?
  not plaintext.nil?
end