class Flagdoc::Store
Store
parsed flags informations
@since 0.1.0
Attributes
files[R]
Public Class Methods
new()
click to toggle source
Store
files data with flags infos
# File lib/flagdoc/store.rb, line 9 def initialize @files = [] end
Public Instance Methods
add(args)
click to toggle source
Add flag to file path if already exist then add file path and flag to @files
@since 0.1.0
# File lib/flagdoc/store.rb, line 17 def add(args) return unless valid?(args) flag = serialize_flag(args) file = find_by_path(args[:path]) if file file[:flags] << flag else add_file(args, flag) end end
Private Instance Methods
add_file(args, flag)
click to toggle source
# File lib/flagdoc/store.rb, line 42 def add_file(args, flag) @files << { path: args[:path], flags: [flag] } end
find_by_path(path)
click to toggle source
@return [Hash] file with path
# File lib/flagdoc/store.rb, line 38 def find_by_path(path) @files.find { |file| file[:path] == path } end
serialize_flag(args)
click to toggle source
# File lib/flagdoc/store.rb, line 46 def serialize_flag(args) { type: args[:type], priority: args[:priority], line: args[:line], description: args[:description] } end
valid?(args)
click to toggle source
@return [Boolean] true if all args are ok
# File lib/flagdoc/store.rb, line 33 def valid?(args) Priority.available?(args[:priority]) end