class NeonRAW::Objects::Rule
The subreddit rule object. @!attribute [r] kind
@return [String] Returns the kind of rule.
@!attribute [r] description
@return [String] Returns the description of the rule.
@!attribute [r] short_name
@return [String] Returns the name of the rule.
@!attribute [r] priority
@return [Integer] Returns the priority of the rule.
@!attribute [r] description_html
@return [String] Returns the description of the rule with HTML.
Public Class Methods
new(client, data)
click to toggle source
@!method initialize(client, data) @param client [NeonRAW::Clients::Web/Installed/Script] The client
object.
@param data [Hash] The object data.
# File lib/NeonRAW/objects/rule.rb, line 23 def initialize(client, data) @client = client data.each do |key, value| # for consistency, empty strings/arrays/hashes are set to nil # because most of the keys returned by Reddit are nil when they # don't have a value, besides a few value = nil if ['', [], {}].include?(value) instance_variable_set(:"@#{key}", value) next if key == :created_utc self.class.send(:attr_reader, key) end end
Public Instance Methods
created()
click to toggle source
Says when the rule was created. @!method created @return [Time] Returns when the rule was created.
# File lib/NeonRAW/objects/rule.rb, line 39 def created Time.at(@created_utc).localtime end