Class: Morito::Processor::LineParser

Inherits:
Object
  • Object
show all
Defined in:
lib/morito/processor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#allowObject (readonly)

Returns the value of attribute allow.



72
73
74
# File 'lib/morito/processor.rb', line 72

def allow
  @allow
end

#disallowObject (readonly)

Returns the value of attribute disallow.



72
73
74
# File 'lib/morito/processor.rb', line 72

def disallow
  @disallow
end

#user_agentObject (readonly)

Returns the value of attribute user_agent.



72
73
74
# File 'lib/morito/processor.rb', line 72

def user_agent
  @user_agent
end

Instance Method Details

#allow?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/morito/processor.rb', line 87

def allow?
  @user_agent && @allow
end

#disallow?Boolean

Returns:

  • (Boolean)


91
92
93
# File 'lib/morito/processor.rb', line 91

def disallow?
  @user_agent && @disallow
end

#parse(line) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/morito/processor.rb', line 74

def parse(line)
  clear_permissions

  case line
  when /\AUser-agent:\s+(.+?)\s*(?:#.+)?\z/i
    @user_agent = $1
  when /\ADisallow:\s+(.+?)\s*(?:#.+)?\z/i
    @disallow = $1
  when /\AAllow:\s+(.+?)\s*(?:#.+)?\z/i
    @allow = $1
  end
end