Class | Ohcount::Gestalt::FileRule
In: | lib/gestalt/rules/file_rule.rb
Parent: | Rule

an abstract base class representing a rule based on an individual file‘s attribute (like code content, or filename, etc..)

### Methods

add_instance instances new rules_triggered_by triggered?

### Attributes

min_count | [R] |

### Public Class methods

add_instance(r)

[Source]

    # File lib/gestalt/rules/file_rule.rb, line 36
                            def self.add_instance(r)
                                    instances << r
                            end

instances()

[Source]

    # File lib/gestalt/rules/file_rule.rb, line 32
                            def self.instances
                                    @instances ||= []
                            end

new(args = {})

[Source]

    # File lib/gestalt/rules/file_rule.rb, line 9
                            def initialize(args = {})
                                    args ||= {}
                                    @min_count = 1
                                    args.each do |k,v|
                                            case k
                                            when :min then @min_count = v
                                            else raise ArgumentError.new("Unrecognized option: #{ k.inspect }")
                                            end
                                    end
                                    FileRule.add_instance(self)
                            end

rules_triggered_by(source_file)

[Source]

    # File lib/gestalt/rules/file_rule.rb, line 25
                            def self.rules_triggered_by(source_file)
                                    rules = instances.find_all do |r|
                                            r.trigger_file?(source_file)
                                    end
                                    rules
                            end

### Public Instance methods

triggered?(g)

[Source]

    # File lib/gestalt/rules/file_rule.rb, line 21
                            def triggered?(g)
                                    g.file_rules[self].to_i >= min_count
                            end

[Validate]