Module: Vidalo::Parser
- Included in:
- Connection
- Defined in:
- lib/vidalo/parser.rb
Instance Method Summary collapse
-
#get_inner_text(type: nil, id: nil, node: nil) ⇒ Object
Return string.
-
#get_node_value(node) ⇒ Object
Return string.
Instance Method Details
#get_inner_text(type: nil, id: nil, node: nil) ⇒ Object
Return string
4 5 6 7 8 9 10 11 12 |
# File 'lib/vidalo/parser.rb', line 4 def get_inner_text(type: nil, id: nil, node: nil) if type.nil? || id.nil? || node.nil? raise ArgumentError.new 'Error: You need to define "type", "id" and node name - eg. get_inner_text(type: "package", id: 5355, node: "title")' end result = send_api_request("#{type}/#{id}") result ? get_node_value(result.at('entry').at(node)) : "" end |
#get_node_value(node) ⇒ Object
Return string
16 17 18 19 20 |
# File 'lib/vidalo/parser.rb', line 16 def get_node_value(node) node ? node.text : "" end |