Class: Ronin::Recon::Value

Inherits:
Object
  • Object
show all
Defined in:
lib/ronin/recon/value.rb,
lib/ronin/recon/value/parser.rb

Overview

Base class for all Values classes.

Defined Under Namespace

Modules: Parser

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse(string) ⇒ Values::IP, ...

Parses a value string.

Parameters:

  • string (String)

    The string to parse.

Returns:

Raises:

  • (UnknownValue)

    Could not identify what value the string represents.

See Also:



107
108
109
# File 'lib/ronin/recon/value/parser.rb', line 107

def self.parse(string)
  Parser.parse(string)
end

.value_typeSymbol

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method is abstract.
Note:

This is used internally to map a recon value class to a printable type.

Returns the type or kind of recon value.

Returns:

  • (Symbol)

Raises:

  • (NotImplementedError)


44
45
46
# File 'lib/ronin/recon/value.rb', line 44

def self.value_type
  raise(NotImplementedError,"#{self}.value_type was not defined")
end

Instance Method Details

#==(other) ⇒ Boolean

Compares the value to another value.

Parameters:

  • other (Object)

    The other value.

Returns:

  • (Boolean)

    Indicates that the value matches the other value.



57
58
59
# File 'lib/ronin/recon/value.rb', line 57

def ==(other)
  eql?(other)
end

#as_jsonHash{Symbol => Object}

This method is abstract.

Coerces the value into JSON.

Returns:

  • (Hash{Symbol => Object})

    The Ruby Hash that will be converted into JSON.

Raises:

  • (NotImplementedError)


69
70
71
# File 'lib/ronin/recon/value.rb', line 69

def as_json
  raise(NotImplementedError,"#{self.class}#as_json was not implemented")
end

#to_csvString

Converts the value to a CSV row.

Returns:

  • (String)

    The CSV row.



104
105
106
# File 'lib/ronin/recon/value.rb', line 104

def to_csv
  CSV.generate_line([self.class.value_type,to_s])
end

#to_json(*args) ⇒ String

Converts the value into JSON.

Parameters:

  • args (Array)

    Additional arguments for Hash#to_json.

Returns:

  • (String)

    The raw JSON string.



94
95
96
# File 'lib/ronin/recon/value.rb', line 94

def to_json(*args)
  as_json.to_json(*args)
end

#to_sString

This method is abstract.

Converts the value to a String.

Returns:

  • (String)

    The string value of the value.

Raises:

  • (NotImplementedError)


81
82
83
# File 'lib/ronin/recon/value.rb', line 81

def to_s
  raise(NotImplementedError,"#{self.class}#to_s was not implemented")
end