Class: LastpassCLI::Item
- Inherits:
-
Object
- Object
- LastpassCLI::Item
- Defined in:
- lib/lastpass-cli/item.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attrs) ⇒ Item
constructor
A new instance of Item.
- #set(attribute, value) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(attrs) ⇒ Item
Returns a new instance of Item.
9 10 11 12 13 |
# File 'lib/lastpass-cli/item.rb', line 9 def initialize(attrs) attrs.each do |k, v| set(k.to_s, v) end end |
Class Method Details
.attributes ⇒ Object
3 4 5 |
# File 'lib/lastpass-cli/item.rb', line 3 def self.attributes %w[id name folder username modified_at password notes number url] end |
Instance Method Details
#set(attribute, value) ⇒ Object
15 16 17 18 19 |
# File 'lib/lastpass-cli/item.rb', line 15 def set(attribute, value) if self.class.attributes.include?(attribute) send("#{attribute}=", value) end end |
#to_h ⇒ Object
21 22 23 24 25 |
# File 'lib/lastpass-cli/item.rb', line 21 def to_h self.class.attributes.each_with_object({}) do |attr, hsh| hsh[attr] = send(attr) end end |