Module: Linode::Ip

Defined in:
lib/linode/ip.rb,
lib/linode/ip/version.rb

Overview

Method for fetching ip of linode matching a label.

Defined Under Namespace

Classes: Error

Constant Summary collapse

VERSION =
'1.0.1'

Instance Method Summary collapse

Instance Method Details

#fetch(name) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/linode/ip.rb', line 11

def fetch(name)
  matched_linodes = maching_linodes(linodes, name)

  return if matched_linodes.empty?

  return matched_linodes[0]['ipv4'].first if matched_linodes.count == 1

  n = select_linodes_index(matched_linodes)

  if n == 'u'
    fetch(read_matcher)
  else
    matched_linodes[n]['ipv4'].first
  end
end