Class: OsCtld::SendReceive::Log::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/osctld/send_receive/log.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Options

Returns a new instance of Options.

Parameters:

  • opts (Hash)

Options Hash (opts):

  • :ctid (String)
  • :port (Integer)
  • :dst (String)
  • :cloned (Boolean, nil)


40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/osctld/send_receive/log.rb', line 40

def initialize(opts)
  @ctid = opts.delete(:ctid)
  @port = opts.delete(:port)
  @dst = opts.delete(:dst)
  @cloned = opts.delete(:cloned)
  @key_name = opts.delete(:key_name)
  @snapshots = opts.delete(:snapshots)

  unless opts.empty?
    raise ArgumentError, "unsupported options: #{opts.keys.join(', ')}"
  end
end

Instance Attribute Details

#clonedBoolean

Parameters:

  • cloned (Boolean)

Returns:

  • (Boolean)


27
28
29
# File 'lib/osctld/send_receive/log.rb', line 27

def cloned
  @cloned
end

#ctidString (readonly)

Returns:

  • (String)


17
18
19
# File 'lib/osctld/send_receive/log.rb', line 17

def ctid
  @ctid
end

#dstString (readonly)

Returns:

  • (String)


23
24
25
# File 'lib/osctld/send_receive/log.rb', line 23

def dst
  @dst
end

#key_nameString (readonly)

Returns:

  • (String)


30
31
32
# File 'lib/osctld/send_receive/log.rb', line 30

def key_name
  @key_name
end

#portInteger (readonly)

Returns:

  • (Integer)


20
21
22
# File 'lib/osctld/send_receive/log.rb', line 20

def port
  @port
end

#snapshotsBoolean (readonly)

Returns:

  • (Boolean)


33
34
35
# File 'lib/osctld/send_receive/log.rb', line 33

def snapshots
  @snapshots
end

Class Method Details

.load(cfg) ⇒ Object



12
13
14
# File 'lib/osctld/send_receive/log.rb', line 12

def self.load(cfg)
  new(Hash[cfg.map { |k,v| [k.to_sym, v] }])
end

Instance Method Details

#[](opt) ⇒ Object

Parameters:

  • opt (Symbol)


54
55
56
# File 'lib/osctld/send_receive/log.rb', line 54

def [](opt)
  instance_variable_get(:"@#{opt}")
end

#cloned?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/osctld/send_receive/log.rb', line 58

def cloned?
  cloned ? true : false
end

#dumpObject



62
63
64
65
66
67
68
69
70
71
# File 'lib/osctld/send_receive/log.rb', line 62

def dump
  {
    'ctid' => ctid,
    'port' => port,
    'dst' => dst,
    'cloned' => cloned?,
    'key_name' => key_name,
    'snapshots' => snapshots,
  }
end