Method: Nostr::Filter#to_h

Defined in:
lib/nostr/filter.rb

#to_hHash

Converts the filter to a hash, removing all empty attributes

Examples:

filter.to_h # =>
{
   ids: ['c24881c305c5cfb7c1168be7e9b0e150'],
   authors: ['000000001c5c45196786e79f83d21fe801549fdc98e2c26f96dcef068a5dbcd7'],
   kinds: [0, 1, 2],
   '#e': ['7bdb422f254194ae4bb86d354c0bd5a888fce233ffc77dceb3e844ceec1fcfb2'],
   '#p': ['000000001c5c45196786e79f83d21fe801549fdc98e2c26f96dcef068a5dbcd7'],
   since: 1230981305,
   until: 1292190341
}

Returns:

  • (Hash)

    The filter as a hash.


149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/nostr/filter.rb', line 149

def to_h
  {
    ids:,
    authors:,
    kinds:,
    '#e': e,
    '#p': p,
    since:,
    until: self.until,
    limit:
  }.compact
end