Class: Lastpass::Parser Private

Inherits:
Object
  • Object
show all
Defined in:
lib/lastpass-api/parser.rb

Overview

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

Internal class for parsing through Lastpass raw output

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_string, with_passwords: false) ⇒ Parser

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.

Returns a new instance of Parser.

Parameters:

  • raw_string (String)

    Lastpass CLI response string

  • with_passwords (Boolean) (defaults to: false)

    Whether or not to return passwords



18
19
20
21
22
# File 'lib/lastpass-api/parser.rb', line 18

def initialize( raw_string, with_passwords: false )
  @raw_string = raw_string
  @with_passwords = with_passwords
  @all = {}
end

Class Method Details

.parse(raw_string, with_passwords: false) ⇒ Array<Hash>

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.

Method to interact directly with parser

Parameters:

  • raw_string (String)

    Lastpass CLI response string

  • with_passwords (Boolean) (defaults to: false)

    Whether or not to return passwords

Returns:

  • (Array<Hash>)


13
14
15
# File 'lib/lastpass-api/parser.rb', line 13

def self.parse( raw_string, with_passwords: false )
  new( raw_string, with_passwords: with_passwords ).parse_all
end

Instance Method Details

#inspectObject

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.

Hide instance variables and values



37
38
39
40
# File 'lib/lastpass-api/parser.rb', line 37

def inspect
  original_inspect = super
  original_inspect.split( ' ' ).first << '>'
end

#parse_allArray<Hash>

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.

Parse through all lines in raw output

Returns:

  • (Array<Hash>)


27
28
29
30
31
32
# File 'lib/lastpass-api/parser.rb', line 27

def parse_all
  @raw_string.split( "\n" ).each do |line|
    parse_line( line )
  end
  @all.values
end