Class: RIO::Match::Entry::Selector
Direct Known Subclasses
Instance Attribute Summary collapse
-
#nosel ⇒ Object
readonly
Returns the value of attribute nosel.
-
#sel ⇒ Object
readonly
Returns the value of attribute sel.
Instance Method Summary collapse
- #callstr(func, *args) ⇒ Object
- #entry_sel_args ⇒ Object
-
#initialize(entry_sel) ⇒ Selector
constructor
A new instance of Selector.
- #inspect ⇒ Object
- #match?(el) ⇒ Boolean
- #process_entry_sel ⇒ Object
- #skip_type(skip_args) ⇒ Object
- #something_selected? ⇒ Boolean
- #something_skipped? ⇒ Boolean
Constructor Details
#initialize(entry_sel) ⇒ Selector
Returns a new instance of Selector.
153 154 155 156 157 |
# File 'lib/rio/entrysel.rb', line 153 def initialize(entry_sel) @entry_sel = entry_sel @sel = @nosel = nil process_entry_sel() if @entry_sel end |
Instance Attribute Details
#nosel ⇒ Object (readonly)
Returns the value of attribute nosel.
152 153 154 |
# File 'lib/rio/entrysel.rb', line 152 def nosel @nosel end |
#sel ⇒ Object (readonly)
Returns the value of attribute sel.
152 153 154 |
# File 'lib/rio/entrysel.rb', line 152 def sel @sel end |
Instance Method Details
#callstr(func, *args) ⇒ Object
223 224 225 |
# File 'lib/rio/entrysel.rb', line 223 def callstr(func,*args) self.class.to_s+'['+self.to_s+']'+'.'+func.to_s+'('+args.join(',')+')' end |
#entry_sel_args ⇒ Object
158 159 160 |
# File 'lib/rio/entrysel.rb', line 158 def entry_sel_args() @entry_sel['args'] end |
#inspect ⇒ Object
200 201 202 203 204 205 206 |
# File 'lib/rio/entrysel.rb', line 200 def inspect() str = sprintf('#<Selector:0x%08x',self.object_id) str += " @sel=#{@sel.inspect}" str += " @nosel=#{@nosel.inspect}" str += ">" str end |
#match?(el) ⇒ Boolean
220 221 222 |
# File 'lib/rio/entrysel.rb', line 220 def match?(el) yes?(el) and not no?(el) end |
#process_entry_sel ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/rio/entrysel.rb', line 170 def process_entry_sel() sel_args = self.entry_sel_args raise RuntimeError, "Internal error: entry_sel_args not set" unless sel_args if something_selected? @sel = Match::Entry::Sels.new @sel << Match::Entry::List.new(:true?,*sel_args['entries']) if sel_args.has_key?('entries') @sel << Match::Entry::List.new(:file?,*sel_args['files']) if sel_args.has_key?('files') @sel << Match::Entry::List.new(:dir?,*sel_args['dirs']) if sel_args.has_key?('dirs') end if something_skipped? @nosel = Match::Entry::Sels.new if sel_args.has_key?('skipentries') @nosel << Match::Entry::List.new(:true?,*sel_args['skipentries']) end if sel_args.has_key?('skipfiles') @nosel << Match::Entry::List.new(:file?,*sel_args['skipfiles']) unless sel_args['skipfiles'].empty? or sel_args.has_key?('files') @sel ||= Match::Entry::Sels.new @sel << Match::Entry::List.new(:file?) end end if sel_args.has_key?('skipdirs') @nosel << Match::Entry::List.new(:dir?,*sel_args['skipdirs']) unless sel_args['skipdirs'].empty? or sel_args.has_key?('dirs') @sel ||= Match::Entry::Sels.new @sel << Match::Entry::List.new(:dir?) end end end end |
#skip_type(skip_args) ⇒ Object
167 168 169 |
# File 'lib/rio/entrysel.rb', line 167 def skip_type(skip_args) end |
#something_selected? ⇒ Boolean
161 162 163 |
# File 'lib/rio/entrysel.rb', line 161 def something_selected? %w[entries files dirs].any? { |k| entry_sel_args.has_key?(k) } end |
#something_skipped? ⇒ Boolean
164 165 166 |
# File 'lib/rio/entrysel.rb', line 164 def something_skipped? %w[skipentries skipfiles skipdirs].any? { |k| entry_sel_args.has_key?(k) } end |